Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

  1. 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)
  2. State Management: Terraform remote state with locking, separate state per environment
  3. CI Pipeline:
    • Validate: Trivy scan + terraform plan/kubectl diff drift check
    • Plan: Show proposed changes on PR
    • Apply: Deploy on tagged release only
  4. Versioning: Git tags = semantic versions (x.y.z) deployable to any environment
  5. Disaster Recovery: Checkout tag + run just deploy --env=prod with static artifacts from ADR 004

Required Tools & Practices

ToolPurposeStageMandatory
TrivyVulnerability scanningValidateYes
Terraform or kubectl/kustomizeConfiguration managementDeployYes
JustfilesTask automationAllRecommended
devcontainer-baseDev environmentLocalRecommended
k3dLocal testingDevOptional

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.

References