terraform patterns

DevOps Community

Skill notes

Quick Reference

Pattern · When to Use · Reference Hub-Spoke Networking · Multi-workload environments with shared services · references/hub-spoke-pattern.md Private Endpoint Wiring · Any PaaS service requiring private connectivity · references/private-endpoint-pattern.md Diagnostic Settings · Every deployed resource (mandatory) · references/common-patterns.md Conditional Deployment · Optional resources controlled by variables · references/common-patterns.md

Canonical Example — Module Composition

Wire AVM child modules by passing outputs as inputs (module.<name>.<output>); never hardcode IDs. AVM-TF module versions in APEX-generated code MUST be exact semver (version = "X.Y.Z") — pinned at plan time from registry.terraform.io (newest stable in modules[0].versions[]). Range constraints (~> X.Y, >= X.Y.Z) are NOT allowed in 04-iac-contract.json and

Rules

AVM-first: Use Azure/avm-res-* registry modules over raw azurerm_* resources AVM-TF version pins: Exact semver only (version = "X.Y.Z") — resolve the latest stable via registry.terraform.io/v1/modules/Azure/avm-res-{path}/azurerm/versions at plan time. Stale pins need a pin_policy.mode = "exception" block in 04-iac-contract.json. Range constraints (~>, >=) are flagged by validate:avm-versions.

Steps

Applying a Terraform pattern in a root module: Identify the pattern — match your need to a row in Quick Reference (hub-spoke, private endpoint, diagnostics, conditional, identity, budget, plan interpretation) Load the reference — read the linked references/*.md; do not load all at once Compose AVM modules — wire outputs as inputs (see Canonical Example); never hardcode IDs Pin the provider — ~> 4.0 only; do not use >= 3.0 or exact = 4.x.y

Gotchas

Set-type phantom diffs — azurerm_application_gateway, azurerm_lb, azurerm_network_security_group, azurerm_firewall, azurerm_frontdoor: adding ONE element causes ALL elements to show ~ changes. Mitigation: ignore_changes on set-type blocks. Provider pin ~> 4.0 is critical — >= 3.0 crosses breaking

Fluxly profile Runtime and permissions are inferred by Fluxly static checks, not author declarations or runtime test results.
Domain
DevOps
Author-declared agents
No explicit declaration found; this is not inferred or tested compatibility
Static check
88 / 100 · heuristic scan, not runtime safety proof
Runtime evidence
Not run; no isolated runtime test evidence is currently recorded
Author / version / license
@tomevault-io · no license declared
Token usage
Lean
Setup complexity
Plug-and-play
External API key
Not required
Operating systems
macOS · Linux · Windows
Runtime requirements
No explicit requirements detected
Detected file/system behavior
  • Read-only
  • Write / modify
Network behavior
Local-only
Install commands
None (reference only)

Heads up: Tool permissions are not declared; actual access depends on the runtime.

Output preview terraform-patterns.preview
# Canonical Example — Module Composition

Wire AVM child modules by passing outputs as inputs (`module.<name>.<output>`); never hardcode IDs. **AVM-TF module versions in APEX-generated code MUST be exact semver (`version = "X.Y.Z"`)** — pinned at plan time from `registry.terraform.io` (newest stable in `modules[0].versions[]`). Range constraints (`~> X.Y`, `>= X.Y.Z`) are NOT allowed in `04-iac-contract.json` and will be flagged by `npm run validate:avm-versions`. Full code sample (resource group + key vault) and rationale in [`references/module-composition.md`](references/module-composition.md). ---

Discussion

Powered by GitHub Discussions. Sign in with GitHub to comment, react, or subscribe.