Terraform modules that scale with your team, not against it
Reusable Terraform modules are sold as the path to consistency: define infrastructure once, reuse it everywhere, sleep soundly. In practice, the first generation of a team’s modules often becomes the thing everyone works around rather than with. Here’s how to avoid that.
Design for the 80%, expose an escape hatch for the rest
The most common mistake is trying to parameterise everything. You end up with a module that has forty inputs, half of which interact in undocumented ways. Instead:
- Cover the common case with sensible defaults so a caller needs three or four inputs, not forty.
- Provide a deliberate escape hatch (a pass-through variable, an optional override block) for the genuine edge cases.
- Resist the urge to model every future requirement now. You’ll model it wrong.
Version modules like the API they are
A shared module is a public interface. Breaking it breaks other teams’ pipelines. Treat it accordingly:
- Publish to a registry and pin versions in consumers. Never track
main. - Follow semantic versioning and mean it. A changed default is a breaking change.
- Keep a short changelog. Future you, mid-incident, will be grateful.
Make the right thing the easy thing
The goal of a platform is that the paved road is also the fastest road. If following your standards is slower than going around them, engineers will go around them, and they’ll be right to.
module "service" {
source = "app.terraform.io/deploycraft/service/aws"
version = "~> 2.1"
name = "orders-api"
environment = "prod"
# sensible, secure defaults for networking, logging and tagging
}
That should be all it takes to get a compliant, observable, well-tagged service. Everything else (encryption, logging, guardrails) comes from the module, not from the caller remembering to add it.
The takeaway
Good modules are less about clever HCL and more about product thinking: know your users, cover the common path, version responsibly, and make compliance the default rather than a chore. Do that and infrastructure as code stops being a bottleneck and starts being a multiplier.
Need a hand building a platform your team actually enjoys using? Let’s talk.
Working on something similar? DeployCraft can help.
Start a conversation →