githubEdit

ADR-0003

Terraform public modules vs custom modules

Status
Date (Last modified)
Deciders
Accepted 👍🏼

07/22/2023

circle-exclamation
chevron-rightTechnical Issue(s):hashtag

Context and Problem Statement

A Terraform modulearrow-up-right is a great resource for describing the architecture and keeping infrastructure as code DRYarrow-up-right. Open-source modules are published to registry.terraform.ioarrow-up-right. Should we consume Terraform public modules or develop custom modules?

Decision Drivers

Considered Options

Use Terraform public modules.

starstarstarstarstarstarstar

Development of custom Terraform modules.

starstarstarstarstarstarstarstarstarstar

Combination of both.

starstarstarstarstarstar

Decision Outcome

Option 2: Development of custom Terraform modules to fit the needs of the organization and the skills of the employees

Pros and Cons of the Options

Use Terraform public modules

  • 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.

Development of custom Terraform modules

  • 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.

Combination of both

  • Initially, public modules will speed up delivery.

circle-info

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.

Last updated