CloudFormation, StackSets, and golden images: provisioning for SOA-C03
Provisioning and maintaining cloud resources is the practice of creating infrastructure from repeatable definitions — golden images built with EC2 Image Builder, stacks declared in CloudFormation templates or the AWS CDK, and baselines rolled out across accounts and Regions with StackSets — instead of hand-building it in the console. Task 3.1 of SOA-C03 (Domain 3, Deployment, Provisioning, and Automation) produces some of the exam's most recognizable scenarios: an encrypted AMI that other accounts cannot launch, a stack stuck in ROLLBACK_COMPLETE, a resource changed outside CloudFormation, a subnet that ran out of IP addresses mid-deployment. This lesson covers the full task: AMI copy, sharing and retirement, Image Builder and container images, template anatomy, change sets and replacement, stack protection, drift and rollback states, deployment troubleshooting, StackSets and AWS RAM, deployment strategies, and the CDK, Terraform and Git.
What you’ll learn
- Copy, share, encrypt and retire AMIs correctly — cross-Region copies, OU sharing, customer managed keys, deprecate/disable/deregister and the Recycle Bin
- Build and distribute AMIs and container images with EC2 Image Builder pipelines, schedules and test components
- Read a CloudFormation template's Parameters, Mappings, Conditions, Resources and Outputs, and use SSM parameter types, pseudo parameters and exports safely
- Predict what a change set's Replacement value means and protect stacks with termination protection, stack policies, UpdateReplacePolicy and DeletionPolicy
- Diagnose failed deployments caused by subnet sizing, name collisions, capabilities and service-role permissions, and recover from rollback states
- Choose between StackSets (self-managed or service-managed), AWS RAM and Service Catalog for multi-account, multi-Region provisioning
- Roll new images through Auto Scaling groups with instance refresh or CloudFormation UpdatePolicy, and position the CDK, Terraform and Git
The 12 parts · about 13 min of reading
- Golden imagesStart hereAn AMI is a registration pointing at EBS snapshots; a cross-Region copy gets a new ID, a destination-Region key and no sharing.1 min
- Sharing AMIs across accounts and organizationsShare a private AMI with account IDs or an OU ARN, and let target accounts use the customer managed key that encrypts it.1 min
- Retiring AMIsDeprecate hides, disable blocks launches everywhere, deregister removes; snapshots stay billed and Recycle Bin needs two rules.1 min
- EC2 Image Builder and container imagesImage Builder pipelines build AMIs or container images from shared components, gate them on tests, then distribute and retire them.1 min
- CloudFormation template anatomy for operatorsResources is the only required section; parameters, conditions, SSM AMI lookups, pseudo parameters and exports make templates reusable.1 min
- Stack updates, change sets, and replacementChange sets preview every Add, Modify and Remove before execution; Replacement True means a new physical resource with new IDs.1 min
- Protecting stacks and stateful resourcesTermination protection, stack policies, UpdateReplacePolicy and DeletionPolicy each guard a different event, so stateful resources need two.1 min
- Drift detection and rollback statesDrift detection reports but never reverts and checks only declared properties; failed creates and failed updates roll back differently.1 min
- Troubleshooting a failed deploymentStart at the first failure event, then fix subnet exhaustion, name clashes, capacity errors and missing IAM capabilities or role rights.2 min
- Multi-account and multi-Region provisioningStackSets copy one template to many accounts and Regions, AWS RAM shares one resource like subnets, Service Catalog offers vetted products.1 min
- Deployment strategiesIn-place is fastest, blue/green rolls back instantly, rolling replaces batches; instance refresh and UpdatePolicy roll out new AMIs.1 min
- The AWS CDK, Terraform, and GitThe CDK deploys ordinary CloudFormation stacks after bootstrap, Terraform keeps a state file to lock, and Git drives reviewed applies.1 min
Mind map
How the exam tests this
Task 3.1 questions are scenario-first: an image must reach other accounts or Regions, a stack fails or drifts, or a baseline must reach every account, and you pick the mechanism. Expect the AMI details — copies are Regional and re-encrypted, permissions don't copy, aws/ebs can't be shared, snapshots outlive deregistration — and the CloudFormation event-to-mechanism mapping: change set to preview, termination protection versus stack policy versus UpdateReplacePolicy versus DeletionPolicy, drift detection that only reports, ROLLBACK_COMPLETE versus UPDATE_ROLLBACK_FAILED. Troubleshooting covers subnet arithmetic (5 reserved addresses, no resizing), global IAM names, capabilities and iam:PassRole for service roles. Multi-account items contrast self-managed and service-managed StackSets with RAM's shared VPCs, and deployment items contrast instance refresh settings with CloudFormation UpdatePolicy.
Key takeaways
- AMIs are Regional: copy them ahead of need; a copy is re-encrypted with a destination-Region key and must be shared again.
- Share encrypted AMIs only under a customer managed key that target accounts can use — never aws/ebs; share with an OU ARN to cover future accounts.
- Deregister an AMI before deleting its snapshots (a disabled AMI still blocks deletion); deprecate only hides, disable blocks launches reversibly.
- Image Builder: schedules can wait for dependency updates, test components gate distribution, container recipes output to ECR.
- Replacement creates a new physical resource (new ID and IP) and deletes the old one at cleanup; custom-named resources can't be replaced.
- Termination protection stops stack deletes, stack policies stop updates, UpdateReplacePolicy covers replacement and DeletionPolicy covers deletion.
- Drift detection checks only properties the template sets and never reverts; ROLLBACK_COMPLETE means delete and recreate.
- Every subnet loses 5 addresses and can't be resized — add CIDR space and subnets; IAM names are account-global, and a service role needs iam:PassRole.
Part 1: Golden images
An AMI is a registration pointing at EBS snapshots; a cross-Region copy gets a new ID, a destination-Region key and no sharing.
Frequently asked questions
What is the difference between CloudFormation StackSets and AWS RAM?
StackSets deploy a copy of one CloudFormation template into many accounts and Regions, so each account gets its own stack of resources; with service-managed permissions, accounts joining a targeted OU receive the stack automatically (the management account is never included). AWS RAM instead shares a single existing resource — such as VPC subnets or a Transit Gateway — so other accounts use the owner's resource in place. Use StackSets to replicate infrastructure and RAM to share it.
Why can't another account launch my shared encrypted AMI?
Launch permission on the AMI is not enough when its snapshots are encrypted: the other account also needs permission to use the KMS key. The AWS managed aws/ebs key's policy can't be changed, so an AMI encrypted with it can't be shared usefully — re-encrypt it with a customer managed key, grant the target accounts use of that key, and share the new AMI. After a cross-Region copy, share the copy again and grant the destination Region's key, because launch permissions are not copied.
Does deregistering an AMI delete its snapshots?
No, not by default. Deregistering removes the AMI, but its EBS snapshots remain and keep incurring storage charges until they are deleted; DeregisterImage can optionally delete them in the same call. EC2 refuses to delete a snapshot that still backs a registered AMI, including a disabled one, so deregister first and delete the snapshots second.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.