- Launch Templates and minimal
user-datafor immutable AMIs - CloudFormation patterns:
CreationPolicy,UpdatePolicy(AutoScalingRollingUpdate), andcfn-signal - ASG-native instance refresh vs CloudFormation-driven replacements
- Recommended deployment strategies and exam tips
Immutable vs Mutable: quick comparison
EC2 Image Builder or other bake pipelines create the golden AMI you will reference in a Launch Template / ASG so every instance launched from that AMI has identical configuration.
Launch Templates
- Use Launch Templates to describe instance configuration (the modern replacement for launch configurations).
- Launch Templates can contain
ImageId(AMI),InstanceType, IAM instance profile, security groups, monitoring, metadata options, and minimaluser-data. - Versioning a Launch Template is how you tie a specific golden AMI to a deployment.

user-data for an immutable AMI
- Keep
user-dataminimal: start services and signal instance health. - The application and configuration should be baked into the AMI.
CloudFormation template structure (high level)
Below are the key CloudFormation sections used in this demo to demonstrate immutable deployments via Launch Template versioning, Auto Scaling rolling updates, and instance signaling. Parameters (partial):VersionDescription and ImageId are how you tie a specific golden AMI to a launch template version. Launch template versions persist; you can reference specific versions or use LatestVersionNumber.
Auto Scaling Group (key bits)
- The ASG references the Launch Template by
LaunchTemplateIdandVersion(for exampleLatestVersionNumber). UpdatePolicywithAutoScalingRollingUpdatecontrols how CloudFormation performs instance replacements during stack updates.CreationPolicywithResourceSignalinstructs CloudFormation to wait for instances to signal healthy viacfn-signal.
CloudFormation stack creation and signals
When creating/updating the stack, CloudFormation provisions resources. TheCreationPolicy plus cfn-signal from user-data informs CloudFormation when instances are ready. If the stack shows CREATE_IN_PROGRESS, check the CloudFormation Events tab for resource signaling and health information.

Instance refresh and Auto Scaling native replacement
- Auto Scaling’s built-in Instance Refresh lets you replace ASG instances (for example after updating the launch template version).
- Instance refresh is independent of CloudFormation; it can be started from the ASG console, CLI, or SDKs.
- If you prefer CloudFormation-driven replacements, update the Launch Template or ASG in a stack change set; CloudFormation will respect
UpdatePolicyandCreationPolicyduring updates.


Deployment strategies and exam tips
Use Launch Templates (not launch configurations). Combine CloudFormation
UpdatePolicy (AutoScalingRollingUpdate), CreationPolicy with cfn-signal, and ASG Instance Refresh for smooth immutable workflows. For large-scale blue/green workflows, prefer AWS CodeDeploy (with CloudFormation integration) rather than manual ALB target switching in exam scenarios.Key takeaways
- Immutable infrastructure replaces instances with new AMIs instead of mutating running instances — this reduces configuration drift.
- Bake application and configuration into a golden AMI (EC2 Image Builder is commonly used).
- Use Launch Templates and their versioning to point deployments to a specific AMI version.
- Use CloudFormation
UpdatePolicy(AutoScalingRollingUpdate) together withCreationPolicyandcfn-signalto coordinate safe replacements during stack updates. - Use Auto Scaling Instance Refresh for ASG-native replacements, or trigger replacements via CloudFormation updates/change sets.
- Consider AWS CodeDeploy for managed blue/green deployments; manual blue/green is possible (two ASGs + ALB target switching) but CodeDeploy is the recommended approach.
Links and references
- Launch templates — EC2 (concepts)
- Auto Scaling groups — EC2 (concepts)
- CloudFormation — KodeKloud course
- AWS Auto Scaling Instance Refresh
- AWS CodeDeploy documentation
- Application Load Balancer (ALB)