ADR-0003
Terraform public modules vs custom modules
Last updated
Terraform public modules vs custom modules
Last updated
07/22/2023
If superseded by another ADR, include the link here:
A Terraform module is a great resource for describing the architecture and keeping infrastructure as code DRY. Open-source modules are published to registry.terraform.io. Should we consume Terraform public modules or develop custom modules?
Developers at all skill levels should be able to contribute and maintain over time.
The interfaces provided to the consumer should be simple and focused.
Security and other policies should align with organizational requirements.
Good balance between DRY and Keep it simple, stupid (KISS).
Align with Hashicorp documentation.
Single testing framework.
Option 2: Development of custom Terraform modules to fit the needs of the organization and the skills of the employees
If the module meets all our requirements right now, we do not have to write or maintain any code.
We can adhere to the DRY principle.
Initially, they will speed up delivery.
We can balance DRY and KISS.
New developers are more comfortable submitting PRs and learning git within the organization's context.
We have control over the interfaces.
We can align with organizational security policies.
Initially, public modules will speed up delivery.
The Terraform documentation seems a bit outdated in reference to when to write a module. For example, "If you have trouble finding a name for your module that isn't the same as the main resource type inside it, that may be a sign that your module is not creating any new abstraction, so the module is adding unnecessary complexity." This is not what you see in their module registry, and it is very common to see a module with the same name as the main resource type. Even tho the words "may be" are used we feel this gives an incorrect initial first impression and should focus more on the drivers for when to write a module. See ADR-0004 for more information.
Use Terraform public modules.
Development of custom Terraform modules.
Combination of both.