Immutable infrastructure
Immutable infrastructure on AWS - replacing resources instead of patching them in place, with golden AMIs from EC2 Image Builder, infrastructure as code, blue/green and canary deployments, and drift detection.
Not in the course slides
Immutable infrastructure is on the exam guide's list of concepts (Domain 2) but not in the course slides. This page is written from the AWS documentation (Well-Architected best practice REL08-BP04).
What it is
Immutable infrastructure means no updates, security patches or configuration changes happen in place on production resources. When something must change, the team builds new resources with the change, tests them, moves traffic to them and throws the old ones away.
- Mutable (the old way): SSH into the servers and patch them. Over months each server drifts a little from the others, and nobody knows exactly what's on them.
- Immutable: servers are like cattle, not pets. Version 2 is a new image on new instances; version 1 is deleted.
Why it helps
- Consistency: every environment runs the same tested image, so testing is simpler.
- No configuration drift: resources are always in a known, version-controlled state.
- Atomic deployments: a deployment either completes or nothing changes.
- Fast, safe rollback: the previous version still exists; switch back to it.
- Better security: with no in-place changes, SSH and remote access can be turned off entirely.
How to do it on AWS
- Prebake images: EC2 Image Builder pipelines build, patch, test and distribute golden AMIs (and container images) on a schedule.
- Infrastructure as code: CloudFormation (or the CDK) declares every resource, stored in source control. A change is a new template version, not a console click.
- Deployment patterns:
- Blue/green: a full new fleet (green) runs beside the old one (blue); switch traffic all at once or gradually (ALB weighted target groups, Route 53 weighted records), then delete blue. CodeDeploy and Elastic Beanstalk support it.
- Canary: send a small share of users to the new version, watch errors, then roll out further or roll back. CodeDeploy supports canary configurations (including for Lambda and ECS).
- Auto Scaling instance refresh: replace instances in an ASG with ones from a new launch template, in batches.
- Detect drift: CloudFormation drift detection and AWS Config rules find anything changed by hand.
- Disallow in-place changes: IAM policies (and SCPs) that stop people modifying running production resources.
Containers and Lambda are immutable by design: each deployment is a new image or a new function version.
Real-world examples
- A bank rebuilds its golden AMI with EC2 Image Builder every week, runs its security tests in the pipeline, and rolls the new AMI out with an ASG instance refresh. Nobody has SSH access to production.
Exam tips
- "Avoid configuration drift, replace instead of patching" → immutable infrastructure: new AMI + new instances.
- "Automate building and patching AMIs" → EC2 Image Builder.
- "Deploy with near-zero downtime and instant rollback" → blue/green (CodeDeploy, Elastic Beanstalk, Route 53 weighted).
- "Test a new version on a small share of traffic first" → canary deployment.
- "Find resources changed outside CloudFormation" → drift detection.
Common traps
- "Use Systems Manager Patch Manager on production servers" when the question asks for immutable infrastructure. Patching in place is mutable; patch the image and replace the instances.
- "Blue/green halves the cost." For a while both fleets run; it costs more during the switch.
Check yourself
Build a patched golden AMI each month with an EC2 Image Builder pipeline, put it in a new launch template version, and replace the instances (an ASG instance refresh, or a blue/green switch behind the ALB). Roll back by going back to the previous launch template.
AWS documentation
Well-Architected Framework and Trusted Advisor
The AWS Well-Architected Framework's general design principles and six pillars, the free Well-Architected Tool for reviewing workloads, AWS Trusted Advisor's checks and support plans, and where to find reference architectures.
Exam Prep
How to get ready for SAA-C03 and what happens on exam day - practice, answering by elimination, whitepapers and FAQs, booking, time management, scoring, results and retakes.