𝗧𝗵𝗲 𝗽𝗿𝗼𝗯𝗹𝗲𝗺
Many teams start with Terraform by running "terraform apply" locally. It works... until it doesn't. Without a controlled workflow, uncomfortable questions start showing up: who applied that change in production? why wasn't there an approval before a destroy? where does the state live, and who has access to it?
𝗧𝗵𝗲 𝘀𝗼𝗹𝘂𝘁𝗶𝗼𝗻
I designed an architecture where every infrastructure change follows the same path:
GitHub (push to main) → CodePipeline → CodeBuild (plan) → Manual approval → CodeBuild (apply)
And in parallel, SNS notifications and full traceability for every execution.
𝗪𝗵𝗮𝘁 𝗜 𝘁𝗵𝗶𝗻𝗸 𝗺𝗮𝘁𝘁𝗲𝗿𝘀 𝗺𝗼𝘀𝘁 𝗶𝗻 𝘁𝗵𝗲 𝗱𝗲𝘀𝗶𝗴𝗻:
🔐 MFA enforced and least-privilege IAM roles — no wildcards, no static credentials. CodeBuild assumes temporary roles, period.
🛑 Dual approval for destroy operations — if the plan detects a resource destruction, the pipeline requires a second approver, with a 60-minute timeout and automatic cancellation. An accidental "terraform destroy" no longer wipes out production with a single click.
📋 365-day audit trail — every execution is logged with the initiator's identity, changed resources, timestamps, and results. CloudTrail + EventBridge + Lambda do the heavy lifting.
🔑 Encryption at rest — S3, DynamoDB, and CloudTrail all share a customer-managed KMS key with automatic rotation.
🕵️ Credential leak detection — CloudWatch metric filters alert on AWS key patterns showing up in build logs.
✅ Pull Request validation — every PR triggers a "terraform plan" and posts the result as a comment, blocking the merge if it fails.
🔄 90-day permission recertification — a Lambda function checks (and can revoke) access that's no longer being used.
𝗢𝗻𝗲 𝗱𝗲𝘁𝗮𝗶𝗹 𝗜 𝗽𝗮𝗿𝘁𝗶𝗰𝘂𝗹𝗮𝗿𝗹𝘆 𝗹𝗶𝗸𝗲: VPC network isolation was intentionally left out to save around $22/month, compensating for it with strict IAM role scoping instead. It's a good example that "secure" doesn't always mean "the most complex architecture possible" — sometimes it means making informed decisions about where to put the effort.
𝗧𝗵𝗲 𝗿𝗲𝘀𝘂𝗹𝘁
All of this running on ephemeral CodeBuild containers (no EC2 instances to maintain), at an estimated cost of ~$5/month for 10 pipeline runs a month.
Projects like this confirm something for me: security and governance in IaC don't have to slow down delivery. With the right design, they're what let you move fast with confidence.
How does your team handle change control and approvals in your Terraform pipelines? I'd love to hear other approaches. 👇
#Terraform #AWS #DevOps #InfrastructureAsCode #CICD #CloudSecurity #IaC
Loading article