Replacing Instead of Changing with Immutable Infrastructure
This lesson explains immutable infrastructure, in which servers are replaced rather than changed after deployment, and the automation strategies that keep infrastructure in its intended state, as the exam guide lists.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish mutable from immutable infrastructure.
- Describe how immutable deployments are implemented on AWS.
- Explain how automation protects infrastructure integrity.
Mutable compared with immutable infrastructure
With mutable infrastructure, running servers are updated in place: patches, configuration changes and new application versions are applied to the same instances. Over time, instances that started identical drift apart, and a failed update can leave a server half-changed. With immutable infrastructure, every change is built into a new image, such as a new AMI or container image, and new instances or tasks replace the old ones; nothing is changed by hand. The following table compares the two.
Mutable or immutable?
Implementing immutable deployments on AWS
In immutable infrastructure, servers are never changed after they are deployed; a change is made by replacing them with new ones built from a new image. On EC2, a golden AMI containing the operating system, patches and application is built by an automated pipeline, for example with EC2 Image Builder, and a new launch template version references it. An Auto Scaling instance refresh then replaces running instances with ones from the new version, in batches, keeping a minimum percentage healthy.
Blue/green deployments run the new version in a separate environment and switch traffic to it with a load balancer or Route 53, keeping the old environment for instant rollback. Elastic Beanstalk immutable deployments launch a full set of new instances in a temporary Auto Scaling group. Containers on ECS or EKS are immutable by nature: a new image means new tasks or pods.
The following diagram shows the pipeline from image to running instances.

An immutable EC2 deployment
Automation that protects infrastructure integrity
Immutable deployments are reinforced by automation that detects or prevents unapproved changes. Defining infrastructure in CloudFormation makes it reproducible, and drift detection reports resources that were changed outside the template. AWS Config rules evaluate resources continuously and can remediate non-compliant ones automatically. Removing SSH access and using Systems Manager Session Manager for exceptional access, with logging, discourages manual changes. Stack policies and termination protection guard critical resources against accidental updates or deletion.
A company patches a fleet of 50 web servers in place every month. Some servers fail to patch, others were changed by hand during incidents, and no two servers are exactly alike, which makes problems hard to reproduce. How should the architect redesign the process?
The architect moves to immutable infrastructure. An automated pipeline builds a patched golden AMI each month and creates a new launch template version, and an Auto Scaling instance refresh replaces the instances in batches while keeping at least 90% of capacity healthy, rolling back if health checks fail. SSH is removed and Session Manager is used for diagnostics. The stack is managed in CloudFormation with drift detection, and AWS Config rules flag any instance that is not running the approved AMI. Every server now matches a known image, and a bad image is rolled back by returning to the previous launch template version.
How is a change made in immutable infrastructure?
Show answer
By building a new image or version and replacing the running instances, never by changing them in place, so configuration cannot drift and rollback means returning to the previous image.
Exam Tips
Remember for the exam
- Immutable infrastructure replaces resources instead of changing them, which prevents configuration drift.
- Golden AMIs with launch template versions and instance refresh roll out changes immutably.
- Blue/green deployments and Elastic Beanstalk immutable deployments allow fast rollback.
- Use CloudFormation drift detection and AWS Config rules to protect infrastructure integrity.