Deployment choices determine which resources change, how users reach a new version, and what recovery requires. These sections compare the behavior of the AWS platform named in each scenario.
Mutable and immutable deployments
A deployment can change existing servers or create replacements. In-place deploymentA release changes application software on existing servers. changes the application on existing instances. Immutable deploymentA release starts a new server set from the desired configuration or application version. starts a new server set from the desired configuration. The AWS deployment methods guide explains these choices.
How it works
- Choose the object being changed. CodeDeploy in-place updates an application revisionA packaged version of application files is selected for deployment., meaning a packaged version of application files, on existing EC2 instances.
- For an immutable server release, prepare the new configuration or image and launch replacement capacity. EC2 Image Builder can build, test, and distribute the machine image first.
- An Auto Scaling group is a managed set of EC2 instances. Its rolling instance refreshAn Auto Scaling operation applies a desired configuration through instance or root-volume replacement. replaces instances in batchesA subset of instances processed together during a rolling deployment. using the desired configuration. Instance refresh also offers a separate root-volume replacement strategy that preserves the instance and its network interfaces.
- Blue/green uses separate old and new environments. Test the replacement environment, shift traffic, and retain the old environment for rollback if needed.
- On Beanstalk, choose the application deployment policy and instance-replacing configuration update policy separately. Use immutable policies for both, or separate the changes, when one release needs both.
Exam cues
- If the question says update code on the same EC2 instances, think CodeDeploy in-place, because it installs a revision on existing servers.
- If the question says replace an Auto Scaling fleet with a new AMI or instance type, think rolling instance refresh, because it applies the desired launch configuration in batches.
- If the question says ECS rolling update, think replacement tasks, because ECS does not update the application inside each running task.
Remember
- Mutable means changing existing systems. Immutable server deployment creates new systems from the desired configuration.
- Rolling describes a gradual rollout; the platform determines what gets updated or replaced.
- Blue/green separates environments and shifts traffic after testing.
- Beanstalk application and configuration update policies are configured separately.
Trap: Selecting immutable application deployments in Beanstalk does not automatically select immutable configuration updates. A combined change needs both policies or separate updates.
From the AWS docs (10)
- An in-place CodeDeploy EC2 deployment updates the application revision on existing instances.
- An immutable deployment starts a new server set with the new configuration or application version.
- Blue/green creates another environment, tests it, shifts traffic to it, and can retain the old environment for rollback.
- ECS rolling deployments replace tasks with new tasks rather than updating the running tasks in place.
- The rolling instance refresh strategy replaces EC2 instances in batches using a desired configuration.
- Instance refresh also supports replacing root volumes without terminating instances; this preserves network interfaces and non-root storage.
- EC2 Image Builder automates building, testing, and distributing customized machine images.
- Beanstalk application deployment policy and instance-replacing configuration update policy are separate settings.
- For Beanstalk changes combining a new application version with instance-replacing configuration, use separate updates or configure immutable policies for both.
- For EC2 blue/green behind one Application Load Balancer, changing the listener rule to forward to the green target group switches traffic at once, with no DNS caching delay.
Golden images and bootstrap
A golden AMIA reusable machine image contains preinstalled software and settings for application instances. is a reusable EC2 launch image prepared with the software and settings an application needs. PrebakingApplication components are installed in a machine image before instances launch. puts application componentsInstallation, configuration, or test instructions form a reusable part of an image recipe. into that image. BootstrappingInstallation and configuration run when a new instance starts. runs installation or configuration when an instance starts. AWS deployment guidance recommends combining the two when instances need both quick startup and environment-specific customization.
How it works
- Define an Image Builder recipe, the base image plus build and test components. A component is a set of installation, configuration, or testing instructions. The parent image can come from a Systems Manager parameter, which stores a named configuration value.
- Start the pipeline on demand or evaluate its schedule. With the default dependency-update condition, a scheduled run builds only when matching dependencies have changed. A changed base-image parameter counts as such an update.
- Image Builder launches EC2 infrastructure, applies the recipe, and runs tests. It distributes the image only when all configured tests succeed.
- Distribution can copy the AMI to Regions, grant launch permissions to accounts or organizational groups, write its ID to Parameter Store, and create a launch templateStored EC2 launch settings identify the image and configuration for new instances. version. A launch template stores settings for new EC2 instances.
- Start a rolling instance refreshAn Auto Scaling operation applies a desired configuration through instance or root-volume replacement. to apply the new launch configuration to existing fleet instances. Use warmup, checkpointsA pause after partial instance replacement allows progress to be evaluated., and supported rollback settings to control replacement. Keep remaining environment customization in bootstrap logic such as user dataStartup configuration or scripts are supplied to an EC2 instance at launch., the startup configuration supplied to EC2.
- For cross-account AMI copies, create the Image Builder distribution role in each destination with its managed policy and trust for the source. Encrypted copies also need destination role KMS permissions and key policies that permit destination access in the source and destination Regions. A distribution-phase failure can be retried without rebuilding.
Exam cues
- If the question says large downloads delay EC2 scaling, think prebaking, because the software is installed before instances launch.
- If the question says a new Image Builder AMI must reach an existing fleet, think launch template plus instance refresh, because image publication and fleet replacement are separate operations.
- If the question says publish the tested AMI for later infrastructure deployment, think an output Parameter Store value or launch template version, because distribution can expose the image identifier to consumers.
- If an account only needs to launch a shared encrypted AMI, grant launch and KMS key access; its snapshots do not need separate sharing for launch. An AMI encrypted with the default AWS managed key cannot be shared.
- If a Linux bootstrap script calls AWS APIs, use an instance profile with the required permissions and inspect
/var/log/cloud-init-output.logfor output. - If Image Builder build diagnosis needs the failed instance, turn off termination on failure in the infrastructure configuration.
Remember
- AMIs are Region-specific. Copy them for use in another Region.
- Output parameter data type aws:ec2:image validates the AMI ID.
- Image Builder launch-template setDefaultVersion defaults to true.
- The schedule defaults to EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE; EXPRESSION_MATCH_ONLY builds at every matching time.
- Linux user data runs on first launch by default.
- User data is limited to 16 KB before encoding and is not included in an AMI created from the instance.
Trap: Publishing a new AMI and launch template version does not update existing instances. Start an instance refresh to replace them.
Start the pipeline on demand or evaluate its schedule. The dependency-update condition can skip a scheduled build when dependencies have not changed.
Image Builder uses the recipe and components to build and test an image on EC2 infrastructure.
Only distribute the output image after all configured tests succeed.
Distribution copies or shares the AMI and can publish its ID to a Parameter Store parameter.
Distribution can create a launch template version referencing the new AMI; setDefaultVersion defaults to true.
Start a rolling instance refresh to replace running instances. Image publication alone does not refresh the fleet.
Box details (7)
- Base image
The image recipe selects a parent AMI directly or through a Systems Manager parameter. A changed parameter value can count as a dependency update at schedule evaluation.
- Image Builder
Build and test components customize and validate the image. Configured tests must pass before Image Builder distributes it.
- New AMI
Owned by the build account. AMIs are regional.
- Distribution
Distribution can copy AMIs to Regions, grant launch permissions to accounts or organizational groups, and publish AMI IDs or launch template versions.
- Parameter Store
Data type
aws:ec2:imagemakes Systems Manager validate the value as an AMI ID. Consumers read this parameter.- Launch template
Distribution adds a launch template version with the new AMI ID. It becomes the default version unless
setDefaultVersionis false.- Auto Scaling
A rolling instance refresh replaces existing instances in batches. Warmup and checkpoints support rollout validation; optional rollback has launch-template restrictions.
From the AWS docs (27)
- An AMI contains the software configuration used to launch EC2 instances.
- Prebaking embeds application components in an AMI and can reduce instance startup work.
- Bootstrapping installs or customizes software at instance launch; large downloads and complex setup can slow deployment and scaling.
- Prebaking and bootstrapping can be combined to start instances with software already installed and customize them for their environment.
- An Image Builder recipe selects the base image and build and test components; components contain installation, configuration, or test instructions.
- Image Builder distributes an image only after all configured tests succeed.
- Image Builder launches EC2 instances in the account to customize images and run validation tests.
- AMIs are Region-specific and can be copied to another Region.
- Image Builder AMI distribution settings can copy images to Regions and grant launch permission to accounts, organizations, or organizational units.
- Image Builder distribution can write an output AMI ID into a Systems Manager Parameter Store parameter.
- The Image Builder output parameter data type aws:ec2:image makes Systems Manager validate the value as an AMI ID.
- Image Builder distribution can create a launch template version for the output AMI; setDefaultVersion defaults to true.
- The Image Builder schedule start condition defaults to EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE; EXPRESSION_MATCH_ONLY builds at every matching schedule time.
- When an Image Builder recipe selects its base through a Parameter Store parameter, a changed parameter value counts as a dependency update.
- An Image Builder schedule determines when the pipeline evaluates whether its start condition is satisfied.
- To update existing instances with a new AMI, create or update a launch template and start a rolling instance refresh.
- Rolling instance refresh supports instance warmup, checkpoints, and optional rollback.
- EC2 user data is limited to 16 KB before base64 encoding and is not included when an AMI is created from an instance.
- Linux user data scripts that call AWS APIs need an instance profile with permissions for those calls; cloud-init output is recorded in /var/log/cloud-init-output.log.
- Sharing an encrypted AMI requires access to its KMS key; AMIs backed by snapshots encrypted with the default AWS managed key cannot be shared. Referenced snapshots need not be shared for instance launch.
- Image Builder cross-account AMI copying requires EC2ImageBuilderDistributionCrossAccountRole in each destination account, a managed distribution policy, and trust for the source account.
- For encrypted Image Builder cross-account copies, destination roles need KMS permissions and source key policies must allow destination accounts to use the keys in the source and destination Regions.
- After a distribution-phase failure, Image Builder can retry distribution without rebuilding the image.
- Image Builder terminates build or test instances on failure by default; infrastructure configuration can retain them for troubleshooting.
- To get an encrypted AMI from an unencrypted one, copy it with encryption turned on and a KMS key; the copy's snapshots are encrypted.
- Instance metadata is data about a running EC2 instance, such as its ID and type, that software on the instance can read; it is not the launch script, which is user data.
- EC2 user data can run configuration scripts at launch; Linux user data scripts and cloud-init directives run on first launch by default.
Flashcards
Nothing to review here right now. Pick other topics or another filter.
·
All 19 cards as a list
For EC2 application releases, what separates an in-place CodeDeploy deployment from an immutable deployment?
In-place updates the revision on existing instances. Immutable launches replacement servers with the new configuration or version. Image Builder can build, test, and distribute images for replacement fleets.
An EC2 Auto Scaling group needs a new AMI or instance type across its fleet. Which deployment mechanism should the team choose?
Use an instance refresh with the rolling strategy and the desired launch configuration. It replaces instances in batches. Use CodeDeploy in-place when the requirement is to change the application revision on existing instances.
Does an Amazon ECS rolling deployment modify the application inside each existing task?
No. ECS rolling deployments replace running tasks with new tasks. The term rolling describes gradual rollout and does not imply in-place mutation.
A Beanstalk application uses immutable deployments but an update also changes instance configuration. Is the application deployment policy alone sufficient?
No. Configure immutable updates for both application and instance configuration, or perform separate updates. The two policies are separate.
A blue/green EC2 deployment must switch all traffic instantly with no DNS caching delay. How?
Point the Application Load Balancer listener rule at the green target group.
When should an EC2 deployment combine a prebaked AMI with launch-time bootstrapping?
Prebake application components to reduce launch work, then bootstrap environment-specific customization. Complex setup and large downloads at launch can slow deployment or scaling.
An EC2 Auto Scaling fleet starts slowly because every new instance downloads large dependencies. Which deployment preparation helps?
Prebake those application components into an AMI, then use launch-time bootstrapping only for the remaining customization.
Image Builder published a new AMI and launch template version, but existing Auto Scaling instances still use the old software. What rollout step is missing?
Start an instance refresh using the desired launch configuration. Publishing the image and template version alone does not replace existing instances.
An EC2 Auto Scaling fleet needs a new application version using immutable instances. How should the team roll it out?
Build a new AMI, update the launch template, and start an instance refresh to replace existing instances.
An EC2 fleet takes too long to scale because every instance downloads application software at launch. What image strategy helps?
Prebake the application components into an AMI to reduce startup work.
An administrator creates an EC2 AMI from an instance whose user data configures the application. Will instances launched from that AMI inherit the user data?
No. User data is an instance attribute and is not included in the AMI. Supply it when launching, within the 16 KB raw limit.
An EC2 Linux user data script calls an AWS API and fails during boot. Where should an operator check permissions and output?
Check the instance profile role's API permissions and /var/log/cloud-init-output.log for script output.
An encrypted EC2 AMI must be shared with another account for instance launches. What must be shared?
Grant AMI launch permission and access to its customer managed KMS key. The referenced snapshots need not be separately shared for launch; the default AWS managed key cannot be used for a shared AMI.
A team needs the same tested EC2 image available in multiple AWS Regions. How can Image Builder support an immutable deployment?
Distribute copies of the AMI to the required Regions, then launch instances from those images.
A team publishes a new AMI for its EC2 Auto Scaling group. Does publishing the image replace running instances?
No. Update the launch template and start an instance refresh to replace the existing instances.
An EC2 team wants fast instance startup and environment-specific configuration. How can it combine image and launch strategies?
Prebake common software into the AMI and use bootstrapping for environment-specific customization.
An EC2 Image Builder pipeline must prevent an image from being distributed when validation fails. What should the team configure?
Configure image tests. Image Builder distributes the image only after all configured tests succeed.
How does a team turn an existing unencrypted AMI into an encrypted one?
Copy the AMI with encryption on and a KMS key; the new AMI's snapshots are encrypted.
A company wants each EC2 instance to install software automatically at first launch. Should it use instance metadata or user data?
User data, which runs scripts at launch. Instance metadata only describes the running instance.