ADR 010: Infrastructure as Code
Status: Accepted | Date: 2025-03-10
Context
All environments must be reproducible from source to minimize drift and security risk. Manual changes and missing version control create deployment failures and vulnerabilities.
Compliance Requirements:
Decision
Golden Path
- Git Repository Structure: Single repo per application with
environments/{dev,staging,prod}folders matching AWS account names (e.g.,app-a-infrarepo →app-a-dev,app-a-staging,app-a-prodaccounts) - State Management: Terraform remote state with locking, separate state per environment
- CI Pipeline:
- Validate: Trivy scan +
terraform plan/kubectl diffdrift check - Plan: Show proposed changes on PR
- Apply: Deploy on tagged release only
- Validate: Trivy scan +
- Versioning: Git tags = semantic versions (x.y.z) deployable to any environment
- Disaster Recovery: Checkout tag + run
just deploy --env=prodwith static artifacts from ADR 004
Required Tools & Practices
| Tool | Purpose | Stage | Mandatory |
|---|---|---|---|
| Trivy | Vulnerability scanning | Validate | Yes |
| Terraform or kubectl/kustomize | Configuration management | Deploy | Yes |
| Justfiles | Task automation | All | Recommended |
| devcontainer-base | Dev environment | Local | Recommended |
| k3d | Local testing | Dev | Optional |
Infrastructure as Code Workflow:
Consequences
Benefits:
- Reproducible infrastructure deployments with version control
- Automated drift detection and prevention mechanisms
- Reliable disaster recovery through infrastructure as code
Risks if not implemented:
- Configuration drift creating security vulnerabilities
- Failed rollbacks during critical incident recovery
- Inconsistent environments affecting application reliability