Easy ReviewDOP-C02
SDLC Automation23

EC2 Image Builder

Build and test AMIs and container images, then distribute images and publish AMI identifiers.

EC2 Image Builder automates creating and updating machine and container images. Its pipelines connect recipes, build infrastructure, tests and distribution settings.

Recipes, components, and pipelines

EC2 Image Builder automates creating and updating machine and container images. An Amazon Machine ImageA preconfigured operating system and software image used to launch EC2 instances. (AMI) contains the operating system and software used to launch an EC2 instance. A pipeline connects the instructions, build environment and delivery settings.

How it works

  1. Select a base imageThe starting image to which a recipe applies its components., the starting operating system and software. An image recipeA document selecting a base image and components for an output image. produces an AMI; a container recipe produces a container image.
  2. Add componentsA reusable sequence of image customization or test steps., which are reusable lists of customization or test steps written in YAML or JSON, plain-text data formats. A build component can also contain tests; a standalone test component contains only the test phase.
  3. Attach infrastructure and distribution configurations. Run the pipeline manually or on a schedule.
  4. For container vulnerability scanning, enable scanning and activate Inspector for ECR in the build Region. Image Builder scans a copy pushed to ECR.
Resource What it specifies
Recipe Base image and components
Infrastructure configuration EC2 build and test environment
Distribution configuration Delivery targets, such as ECR repositories for containers
Pipeline Resources and execution schedule

Exam cues

  • If the question says patched AMIs must be built, tested and delivered weekly, think scheduled Image Builder pipeline, because it connects those operations.
  • If the question says build containers and scan them before delivery to ECR, think container recipe and Inspector integration, because Image Builder supports container outputs and vulnerability scanning.
  • If the question says test Amazon Linux 2 on premises, think the VM image for the target hypervisor plus a seed ISO, because the ISO contains initial configuration rather than the operating system.

Remember

  • AMIs and container images use different recipe types.
  • Image Builder image creation has no service charge; the resources it uses can incur charges.
  • Container scanning requires Inspector activation for ECR in the build Region.

Trap: An Amazon Linux 2 seed ISO cannot replace the operating system VM image. Use both to boot the local VM.

From the AWS docs (15)
  • An Image Builder pipeline automates creating and updating AMIs and container images.
  • An AMI contains an operating system and preinstalled software for launching EC2 instances.
  • An image recipe defines a base image and components for an output AMI.
  • A container recipe defines a base image and components for an output container image.
  • A component is a sequence of customization or test steps described in a YAML or JSON document.
  • A test component contains only the test phase; a build component can include a test phase that runs during testing.
  • A pipeline combines a recipe with infrastructure and distribution configurations.
  • Infrastructure configuration defines the EC2 environment used to build and test images.
  • A container pipeline can distribute Docker images to ECR repositories in target Regions.
  • Creating custom AMI and container images with Image Builder has no service charge; underlying EC2, S3, EBS, ECR and Inspector usage can incur charges.
  • Image Builder container scanning uses Inspector on an image copy pushed to ECR and requires Inspector activation for ECR in the build Region.
  • Pipelines can run on a schedule or be started manually.
  • AMI distribution can deliver image copies to target accounts.
  • For on-premises Amazon Linux 2 development and testing, AWS provides a separate VM image for each supported virtualization platform.
  • The Amazon Linux 2 seed.iso contains initial configuration, not operating system files, and is used together with a separate VM image.

Build and test workflows

An Image Builder workflowAn ordered set of steps that Image Builder runs during one image-creation stage. is a versioned list of steps for one image-creation stage. ComponentsA reusable sequence of image customization or test steps. describe customization and tests inside that process. For AMIs, testing a newly launched instance checks the saved image rather than only the machine used to build it.

How it works

  1. Infrastructure configuration supplies an instance profileA container that delivers an IAM role to an EC2 instance., the IAM role permissions delivered to the EC2 instance, plus instance types and networking.
  2. The Build stage runs component build and validate phases. It then creates a snapshotA saved copy of a disk volume used to preserve its data., a saved disk copy, or a container image.
  3. The Test stage launches a fresh instance for AMIA preconfigured operating system and software image used to launch EC2 instances. tests. Container tests use the build instance. All configured tests must succeed before distribution.
  4. Distribution follows successful included stages. A pipeline can omit build or test workflows, so include tests when they are required.
  5. Use S3 application logs and SNS build-status notifications to investigate failures. The instance profile needs s3:PutObject to write application logs to the chosen S3 location. Clear Terminate instance on failure to retain the failed instance.

Exam cues

  • If the question says an AMI installs correctly but fails after launch, think test stage, because it launches an instance from the saved image.
  • If the question says a build component cannot read an S3 object, think instance profile permissions, because the component runs on the build instance.
  • If the question says investigate a failed build interactively, think retain the failed instance, because termination is selected by default in the console.

Remember

  • Included stages run Build, Test, Distribution, in that order.
  • The console selects Terminate instance on failure by default.
  • Workflows are versioned; create a new version or clone to change one.

Trap: A validate phase checks the build instance before image creation. It does not replace launching the resulting AMI for testing.

AMI build and test sequence
12Build instanceiFresh testiDistribute AMIi
  1. Create the AMI and launch a new test instance from it.

  2. Distribute the image after configured tests succeed.

Box details (3)
Build instance

Run build and validate phases, then create an AMI.

Fresh test

Launch a new instance from the AMI and run configured tests.

Distribute AMI

Distribute after configured tests succeed.

From the AWS docs (13)
  • Image Builder workflow stages run in the order Build, Test and Distribution; a stage starts after the previous included stage succeeds.
  • The build stage runs component build and validate phases before creating the snapshot or container image.
  • AMI testing launches a new EC2 instance from the image created during the build stage.
  • Container workflow tests run on the same instance used for building.
  • Image Builder distributes an image only after all configured tests succeed.
  • A pipeline can omit build or test workflows, including building and distributing without tests.
  • A workflow is a versioned YAML resource defining ordered steps for a stage; changing it requires a new version or clone.
  • Infrastructure configuration selects an instance profile that supplies permissions to build and test instances for component actions.
  • An instance profile passes an IAM role to an EC2 instance.
  • An EBS snapshot is a point-in-time copy of data on an EBS volume.
  • Infrastructure configuration selects instance types, subnet and security groups, an S3 application-log location and an SNS build-status notification topic.
  • The Image Builder console selects Terminate instance on failure by default; clearing it retains a failed instance for troubleshooting.
  • Writing Image Builder application logs to S3 requires s3:PutObject on the destination bucket objects in the instance profile.

Schedules and base image updates

An Image Builder schedule controls when a pipeline checks whether it should build. A dependencyAn image-build input whose update can make a scheduled rebuild necessary. is an input that can change, such as the base imageThe starting image to which a recipe applies its components. or a componentA reusable sequence of image customization or test steps. version. A dependency-aware schedule can skip a build when those inputs have not changed.

How it works

  1. Set a cron expression, a calendar-based schedule, or a rate expression, a recurring interval. The timezone defaults to UTC.
  2. Choose the start condition. The default is EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE. Semantic version filtersA version pattern that selects matching versions of an Image Builder resource., rules that select matching resource versions, let it detect newer base images or components.
  3. To follow an AWS managed base AMIA preconfigured operating system and software image used to launch EC2 instances., use an AWS public ParameterA named value in Parameter Store that can hold an AMI identifier. Store parameter, a named value holding the AMI ID. A changed parameter value also counts as a dependency update. Reading it requires ssm:GetParameter.
  4. At schedule evaluation, build if the chosen condition is satisfied. Use EXPRESSION_MATCH_ONLY for every matching cron time. Start a pipeline manually when needed.

Exam cues

  • If the question says rebuild on schedule only when dependencies change, think the default dependency-update condition, because it checks for changed inputs.
  • If the question says always rebuild weekly, think EXPRESSION_MATCH_ONLY, because it does not require an update.
  • If the question says follow the latest AWS managed AMI without editing recipes, think public Parameter Store base-image reference, because the parameter holds the current AMI ID.

Remember

  • Default start condition: EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE.
  • Default timezone: UTC.
  • A base-image parameter value change counts as a dependency update.

Trap: A dependency change does not mean an immediate scheduled execution. The schedule controls when Image Builder checks it.

From the AWS docs (10)
  • An Image Builder schedule expression determines when the service evaluates whether to start a build.
  • Image Builder scheduleExpression accepts cron expressions or rate expressions.
  • The default start condition is EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE.
  • With semantic version filters, the dependency-update condition builds when matching newer base-image or component versions are available.
  • EXPRESSION_MATCH_ONLY builds every time the cron expression matches.
  • A changed value in a Parameter Store parameter used as the recipe base image counts as a dependency update.
  • A recipe can reference a Parameter Store parameter holding a base AMI ID; AWS public parameters can identify the latest AWS managed AMI.
  • Using a Parameter Store base-image reference requires ssm:GetParameter on the parameter.
  • The schedule timezone defaults to UTC when omitted.
  • A manually configured pipeline runs when started explicitly, including with start-image-pipeline-execution.

Launch template and parameter outputs

Image Builder can publish an AMIA preconfigured operating system and software image used to launch EC2 instances. ID for other systems and create a new launch templateA saved set of EC2 launch settings that can include an AMI identifier. version. A launch template stores EC2 launch settings, including the AMI to use. ParameterA named value in Parameter Store that can hold an AMI identifier. Store holds a named value that a separate deployment pipeline can retrieve.

How it works

  1. Add launchTemplateConfigurations to distribution settings to create a version containing the output AMI ID. setDefaultVersion defaults to true; set it to false to leave the default version unchanged.
  2. Add ssmParameterConfigurations to write the distributed AMI ID into a parameter for a destination Region and account. That account must be a distribution target.
  3. Grant the execution role ssm:PutParameter. The default data type, aws:ec2:image, validates the AMI ID and also requires ec2:DescribeImages. An existing parameter must be type String with the same data type; checking it in the current account requires ssm:GetParameter.
  4. A separate deployment pipeline can retrieve the AMI ID with ssm:GetParameter and release it after review. To roll out the launch template change to existing Auto Scaling instances, start an instance refreshAn Auto Scaling operation that rolls out a new configuration to group instances., which updates the group’s instances.

Exam cues

  • If the question says downstream pipelines need the current image identifier, think Parameter Store output, because Image Builder can write the ID during distribution.
  • If the question says instances still run the old AMI after the template changes, think instance refresh, because a template version does not automatically update existing instances.
  • If the question says output AMI validation fails despite write permission, think ec2:DescribeImages, because aws:ec2:image validates the value as an AMI ID.

Remember

  • setDefaultVersion defaults to true.
  • Output parameter data type defaults to aws:ec2:image; text skips AMI-ID validation.
  • Publishing an AMI ID and rolling out instances are separate operations.

Trap: A newly created launch template version does not deploy the AMI to running instances. Use an instance refresh for that rollout.

Publish an AMI separately from its rollout
12Image BuilderiAMI parameteriInstance refreshi
  1. Publish the output AMI ID during distribution.

  2. A separate deployment pipeline reads the ID and starts the instance rollout.

Box details (3)
Image Builder

Distribution writes the output AMI ID to a named parameter.

AMI parameter

A separate deployment pipeline can retrieve the AMI ID.

Instance refresh

A deployment step uses the AMI in a launch template and refreshes the group.

From the AWS docs (11)
  • A launch template stores EC2 launch parameters, which can include the AMI ID.
  • launchTemplateConfigurations makes Image Builder create a launch template version referencing the output AMI.
  • setDefaultVersion defaults to true when omitted.
  • ssmParameterConfigurations stores a distributed output AMI ID in a named Parameter Store parameter for the destination Region and optionally account.
  • The default output parameter data type is aws:ec2:image, which validates the value as an AMI ID; text skips AMI-ID validation.
  • The Image Builder execution role needs ssm:PutParameter for output parameters and ec2:DescribeImages when the data type is aws:ec2:image.
  • An existing output parameter must have type String and a matching data type; checking it in the current account requires ssm:GetParameter.
  • The output parameter account must be a target distribution account for that Region.
  • An Auto Scaling instance refresh rolls out an updated AMI or launch template to the group instances.
  • A new launch template version does not update existing instances automatically.
  • ssm:GetParameter permits retrieving a parameter that holds an AMI ID.

Cross-account and Region distribution

Image Builder distribution delivers an image to selected accounts and Regions. Copying an AMIA preconfigured operating system and software image used to launch EC2 instances. lets the destination account manage its copy. Launch sharing lets another account launch the owner’s AMI. An organizational unitA group of accounts within an AWS organization. (OU) is a group of accounts within AWS Organizations.

How it works

  1. Choose Region and account targets, or grant AMI launch permissions to accounts, organizations or OUs. AMI launch sharing is Regional and retains the owner’s control.
  2. For account copies, create EC2ImageBuilderDistributionCrossAccountRole in each destination account. Attach Ec2ImageBuilderCrossAccountDistributionAccess and configure trust, which names the source account allowed to assume the role.
  3. For encrypted copies, grant access through both KMS key policies and the destination role’s KMS permissions. The destination needs access to source and destination Region keys.
  4. Set encryption for the original AMI in the recipeA document selecting a base image and components for an output image.’s block-device mappingA definition of the storage devices attached to an instance launched from an AMI., which defines its disks. Distribution KMS settings encrypt copies sent to other accounts or Regions.
  5. To reuse build definitions, use an AWS RAM resource shareA collection of resources and the consumers allowed to use them.. It can share componentsA reusable sequence of image customization or test steps., Image Builder images and recipes. Consumers can use them but cannot modify them or obtain cross-Region replication through the share.
Requirement Mechanism Result
Launch another account’s AMI AMI launch permission Owner retains the AMI
Own and modify a delivered AMI Cross-account distribution Destination manages its copy
Reuse a recipe or component AWS RAM resource share Consumers use the shared resource in its Region

Exam cues

  • If the question says each account must own its AMI, think cross-account distribution, because the destination receives a copy it can modify.
  • If the question says reuse centrally maintained recipes, think AWS RAM, because recipes and components are shareable resources.
  • If the question says encrypted AMI distribution fails, think destination role and KMS access, because both identity permissions and key policies must permit the operation.

Remember

  • Destination role: EC2ImageBuilderDistributionCrossAccountRole.
  • Destination managed policy: Ec2ImageBuilderCrossAccountDistributionAccess.
  • AWS RAM sharing does not replicate Image Builder resources across Regions.

Trap: Launch permission does not grant access to an encryption key. AMIs encrypted with the default AWS managed key cannot be shared across accounts.

Encrypted cross-account AMI distribution
Source account / RegionTarget account / Regioncopy1Source AMIKey permits targetiTarget AMIDistribution role + keyi
  1. Image Builder copies the AMI using the destination distribution role and re-encrypts it with the designated target Region key.

Box details (2)
Source AMI

The source key policy must allow destination access.

Target AMI

The destination distribution role needs source-account trust and permissions to use both Region keys.

From the AWS docs (13)
  • AMI distribution settings can copy images to other Regions and target accounts or grant launch permission to accounts, organizations and organizational units.
  • AMI launch sharing retains ownership, permits launching rather than modifying the shared AMI, and is limited to the AMI Region.
  • Cross-account Image Builder distribution delivers an AMI that the destination account can launch or modify.
  • Each destination account needs EC2ImageBuilderDistributionCrossAccountRole with the Ec2ImageBuilderCrossAccountDistributionAccess managed policy and trust for the source account.
  • For encrypted cross-account distribution, destination permissions must allow use of keys in the source and destination Regions.
  • Encrypted cross-account distribution requires source KMS key policies granting destination access and an inline KMS policy on the destination distribution role.
  • An AMI backed by snapshots encrypted with the default AWS managed key cannot be shared across accounts.
  • The recipe block-device mapping encrypts the original source AMI; distribution KMS settings apply to copies sent to other accounts or Regions.
  • AWS RAM shares Image Builder components, images and recipes with accounts, organizations or organizational units.
  • RAM sharing of Image Builder resources is limited to their creation Region and does not replicate them to other Regions.
  • Consumers can use shared Image Builder resources but cannot modify them.
  • AMI distribution can create launch template versions and store output AMI IDs in Parameter Store.
  • Container distribution settings identify destination ECR repositories.

Flashcards

tap to flip
Answer

·

All 23 cards as a list

What does EC2 Image Builder automate, and which resources can still cost money?

Image creation and updates for AMIs and container images. Image Builder has no image-creation service charge; EC2, S3, EBS, ECR and Inspector usage can still cost money.

Which EC2 Image Builder resources define the image contents, build environment and delivery targets?

A recipe selects the base image and components. Infrastructure configuration defines the build environment. Distribution configuration defines delivery targets. A pipeline combines them.

A team needs patched AMIs built, tested and delivered to target accounts weekly. Which EC2 Image Builder setup should it use?

Use a scheduled image pipeline with an image recipe, test components, infrastructure configuration and distribution configuration.

A team needs EC2 Image Builder to build containers, scan them for vulnerabilities and deliver them to ECR. What must it configure?

Use a container recipe and an ECR distribution target. Enable image scanning and activate Inspector for ECR in the build Region.

A team has an Amazon Linux 2 seed.iso but cannot boot an operating system on its local hypervisor. What is missing?

Download the separate Amazon Linux 2 VM image for the hypervisor and attach the seed ISO for initial configuration. The ISO does not contain the operating system.

For an EC2 Image Builder AMI pipeline with tests, what happens between customization and distribution?

Run build and validate phases, create the image, launch a fresh test instance from it, and run tests. Distribution follows successful configured tests.

What does EC2 Image Builder infrastructure configuration control, and how can a failed instance be retained?

It controls instance permissions, instance types, network, logs and SNS notifications. Clear Terminate instance on failure to retain the failed instance; the console selects termination by default.

An EC2 Image Builder AMI pipeline installs an application successfully but the produced image fails to boot correctly. Where should the team test the resulting image?

Use the test stage, which launches a new EC2 instance from the built image. The validate phase runs before image creation.

An EC2 Image Builder component downloads private S3 files and receives AccessDenied. Which build resource needs permission?

The build instance profile needs permission to access those files. Component actions run with the build and test instance permissions.

Does every EC2 Image Builder pipeline necessarily test an image before distributing it?

No. Build and test workflows can be omitted. The successful-test requirement applies to tests that are configured.

How does an EC2 Image Builder schedule decide whether to rebuild an image?

It evaluates the start condition at the scheduled time. The default dependency-update condition requires a matching dependency change; EXPRESSION_MATCH_ONLY builds at every matching cron time.

A team wants EC2 Image Builder to pick up new Amazon Linux base AMIs without editing the recipe each time. What should it configure?

Use an AWS public Parameter Store base-image reference and a schedule with EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE. A changed parameter value counts as a dependency update at schedule evaluation.

An EC2 Image Builder pipeline must build every scheduled week even when its base image and components have not changed. Which start condition fits?

EXPRESSION_MATCH_ONLY. It builds at each matching cron time without requiring dependency updates.

A team updates the Parameter Store value used by an EC2 Image Builder recipe, but its daily pipeline does not run immediately. Is the dependency setting broken?

No. The change counts as a dependency update, but the schedule determines when Image Builder evaluates it. Start the pipeline manually if a run is needed sooner.

Other pipelines need the output AMI ID from EC2 Image Builder without hard-coded image IDs. What should the producer configure?

Add ssmParameterConfigurations to distribution settings. Image Builder writes the output AMI ID to Parameter Store. Its execution role needs ssm:PutParameter and, for aws:ec2:image, ec2:DescribeImages.

EC2 Image Builder updates an Auto Scaling launch template. Does that roll out the AMI to existing instances?

No. Distribution creates a new launch template version; setDefaultVersion is true if omitted. Use an Auto Scaling instance refresh to roll out the AMI to existing instances.

A team wants to review an EC2 Image Builder AMI separately from the infrastructure rollout. How can the image pipeline hand off the result?

Publish the output AMI ID through distribution to Parameter Store. A separate deployment pipeline can retrieve that ID and roll it out with the launch template and an instance refresh.

EC2 Image Builder can write an output parameter but fails when its data type is aws:ec2:image. Which additional permission should the team check?

ec2:DescribeImages. The aws:ec2:image data type validates that the parameter value is an AMI ID.

What delivery and output options can EC2 Image Builder distribution configure?

For AMIs: Region and account copies, launch permissions, encryption, launch template versions and Parameter Store AMI-ID outputs. Container distribution identifies ECR repositories.

EC2 Image Builder must copy an encrypted AMI to another account. Which permissions and encryption setup are required?

Use a shareable customer managed key with destination access in its policy. Configure EC2ImageBuilderDistributionCrossAccountRole, its managed distribution policy, source-account trust and KMS permissions for source and destination keys.

An EC2 Image Builder pipeline must deliver an AMI to another account that can modify its copy. Which distribution approach fits?

Use cross-account distribution to deliver a copy to the destination account.

How can an EC2 Image Builder container pipeline distribute its output image?

Configure container distribution settings with the destination Amazon ECR repositories.

An account must own and modify an AMI produced by EC2 Image Builder. Should the producer only grant launch permission?

Use cross-account distribution to deliver a copy. Launch sharing permits launches but does not transfer ownership or allow modification of the shared AMI.

You finished every topic of DOP-C02!

Your badge turned gold. Next step: book the exam on AWS. Once you pass, add yourself to Who passed.

Share

Share that you finished this certification

I finished every topic of AWS Certified DevOps Engineer - Professional (DOP-C02) on Easy Review. Come study too!