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-infra
repo →app-a-dev
,app-a-staging
,app-a-prod
accounts) - State Management: Terraform remote state with locking, separate state per environment
- CI Pipeline:
- Validate: Trivy scan +
terraform plan
/kubectl diff
drift 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=prod
with 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
Without this approach: Configuration drift, security vulnerabilities, failed rollbacks, and inconsistent environments.
With this approach: Secure, reproducible deployments with reliable disaster recovery and automated drift prevention.