Reusable Terraform for a multi-engine database estate, with remote locking state, secrets injected at apply time, and nothing applied without a plan and a deliberate gate.
Discuss a similar buildReusable Terraform for a multi-engine database estate, so that every environment provisions to the same baseline and a compliance posture becomes reproducible rather than reviewed once and hoped for.
Modules cover relational engines, networking, backup configuration and secret injection. State lives in a locking remote backend, never in version control, because state holds credentials in clear text. Nothing applies without passing a plan on a protected branch and a deliberate human gate.
The engineering interest is not that Terraform was used. It is the specific choices that make a module set safe to change: iteration over a keyed map rather than a positional index, lifecycle rules that stop provider drift restarting a fleet, and the components deliberately left outside automation because automating them causes an outage.
An estate that grew without a provisioning standard has no two environments alike.
The requirement was one code path producing identical, compliant baselines across environments, with credentials injected at run time and a plan reviewable before anything changes.
The module, state and pipeline relationship, and where credentials enter.
Every one of these came from a failure mode with a specific cost.
With index addressing, deleting the second of five resources shifts everything after it down by one. The tool then sees three resources whose identity changed and destroys and recreates them. With a keyed map the address is a stable string, so removing one entry affects exactly that resource. On infrastructure that matters this is closer to a rule than a preference.
Certain blocks drifted on every plan because the provider read back values that never matched what was declared, so each apply proposed changes to every machine and restarted all of them. A configuration-only change would bounce the whole platform. Ignoring those attributes stops that, at the cost that genuine changes to them must be applied deliberately. Verified by comparing process identifiers across the fleet before and after a single-attribute change: only the intended machine restarted.
The component in question runs the pipelines that manage its own infrastructure. A restarting change applied through that pipeline stops the pipeline mid-job, which then cannot write state back or release its lock, so the next run sees the same outstanding change and repeats the cycle. This is a circular dependency rather than a configuration defect, and the honest answer is to exclude it and reconcile in code afterwards.
Two pipeline variables were once silently overriding a declared endpoint and a TLS verification setting. The code said one thing and the pipeline did another, and the most security-relevant setting in the configuration was invisible unless someone opened the CI settings. Credentials still belong in the pipeline. The settings that govern how they are used do not.
State written by a newer binary cannot be read by an older one, so a local run on a newer version can lock the pipeline out permanently. Pinning both sides and matching them is cheap; recovering from a forward-migrated state file is not.
Measured on this build. Nothing here is a client outcome or a contracted result.
This project is the reference implementation behind two Fortis service lines.
Landing zone, automation and hardening declared in code, so an environment is reproducible and a compliance baseline can be demonstrated rather than described.
Multi-engine database provisioning from a single module set, with networking, backup configuration and secret injection handled consistently across engines.
Provisioning standardised as code means a finding fixed once is fixed everywhere, which is the difference between a reviewed posture and a reproducible one.
The decisions that matter here are about failure modes: index shifting, provider drift restarting a fleet, circular dependencies, and invisible pipeline overrides.