Use enhanced AMI distribution capabilities
Image Builder gives you advanced distribution capabilities that separate distribution from the build process. You can distribute an image that you already built, retry an AMI image that failed during its test or distribution phase without rebuilding it, and define multi-stage distribution processes with custom workflows.
Distribute an existing image
The DistributeImage operation distributes an image that Image Builder (or you) already created, without rerunning the build and test phases. Image Builder runs only the distribution phase, using the targets and settings in a distribution configuration that you reference by ARN.
You identify the source image in one of three ways:
-
AMI ID – A standard AMI identifier, such as
ami-0abcdef1234567890. The AMI must exist and be accessible in the Region where you call the operation. -
SSM parameter – An Systems Manager Parameter Store reference in the form
ssm:, where the text after/path/to/parameterssm:is the parameter name or ARN. The parameter must be aStringparameter whose value is a valid AMI ID. -
Image Builder image version ARN – The ARN of an Image Builder image in the Region where you call the operation. The image's output resources must include an AMI in that Region. You can specify a build version ARN that ends with the build number, such as
image/, or a version ARN without the build number, such asmy-image/1.0.0/1image/. Image Builder resolves a version ARN to its latest build in themy-image/1.0.0AVAILABLEstate.
Note
The source image must be an AMI ID, an SSM parameter, or an Image Builder image ARN, and Image Builder doesn't accept an AWS Marketplace product code. The distribution configuration must be in the same Region where you call DistributeImage. You can't pass inline distribution settings to this operation.
Prerequisites
Unlike a pipeline build, DistributeImage takes an execution role at call time. Make sure the following are in place:
-
An Image Builder execution role that Image Builder can assume to perform the distribution. We recommend that you create a custom role with the EC2ImageBuilderExecutionPolicy AWS managed policy attached. That policy allows
ec2:ModifyImageAttribute,ec2:ModifySnapshotAttribute, andec2:EnableFastLaunchonly on resources that are taggedCreatedBy: EC2 Image Builder, and allowsssm:PutParameteronly on parameters under/imagebuilder/. If your distribution acts on other resources, add the required permissions to the role. To configure EC2 Fast Launch without a launch template, also attach the EC2FastLaunchFullAccess policy. To configure EC2 Fast Launch with a launch template, the launch template must have theCreatedBy: EC2 Image Buildertag. Image Builder adds this tag only to launch templates that the distribution configuration updates inlaunchTemplateConfigurations. For any other launch template, add the tag yourself or attach the EC2FastLaunchFullAccess policy. -
Permission to call
imagebuilder:DistributeImage,imagebuilder:GetDistributionConfiguration, andiam:PassRolefor the execution role. Image Builder also describes the source AMI with your credentials to validate it, so you needec2:DescribeImagesfor every source type. If the source is an SSM parameter, you also needssm:GetParameterfor that parameter. If the source is an Image Builder image ARN, you also needimagebuilder:GetImageon that image. If you include tags in the request, you also needimagebuilder:TagResource. -
If the distribution configuration copies the AMI to other accounts (
targetAccountIds), or updates launch templates or SSM parameters in other accounts, theEC2ImageBuilderDistributionCrossAccountRolein each of those accounts, with the Ec2ImageBuilderCrossAccountDistributionAccess policy managed policy attached. The managed policy doesn't cover launch templates or SSM parameters. To update them, also add the policies that Set up cross-account AMI distribution with Image Builder lists forlaunchTemplateConfigurationsand Parameter Store parameters.
Retry a failed image
If an image fails during its test or distribution phase, use the retry-image
Prerequisites
Before you retry a failed image, verify the following. A retry counts against your concurrent image build quota, and Image Builder rejects the retry if you've already reached that quota.
-
The image is in a
FAILEDorCANCELLEDstate, and it failed or was canceled during its test or distribution phase. You can't retry an image that succeeded or is still in progress, or an image that failed or was canceled in any other phase. -
The image was created within the last 30 days.
-
The image is an AMI-based image. You can't retry a container image.
-
The image hasn't already been retried the maximum number of times. Image Builder allows up to 10 retries per image.
-
You have identified and resolved the root cause of the failure. Review the image's logs in CloudWatch Logs for error details.
-
You have permission to call
imagebuilder:RetryImageon the image build version that you want to retry. -
For cross-account distribution failures, verify that the
EC2ImageBuilderDistributionCrossAccountRolein the destination account has the Ec2ImageBuilderCrossAccountDistributionAccess policy managed policy attached. For more information, see Set up cross-account AMI distribution with Image Builder.
Distribution workflows
Distribution workflows are a workflow type that complements build and test workflows. A distribution workflow defines the distribution phase as a sequence of steps, which gives you step-level visibility and control over how Image Builder distributes an AMI. The steps that this section describes apply to AMI output images.
In a distribution workflow, you can include steps that do the following:
-
Copy and share the AMI across Regions and accounts.
-
Modify image attributes, such as launch permissions, on the distributed AMIs.
-
Apply additional image configurations.
-
Pause for a manual approval or an external callback with a wait-for-action step. This lets you build staged or gated rollouts – for example, distribute to a test Region, wait for approval, then continue to production Regions.
Each step reports its own status – PENDING,
RUNNING, WAITING (wait-for-action steps only),
COMPLETED, FAILED, SKIPPED, or
CANCELLED – and Image Builder sends step-level
details to your CloudWatch log group. A step that runs longer than its
timeoutSeconds value reports FAILED. Image Builder also emits
EventBridge events at key points – for example, when the image changes state, and when a
wait-for-action step pauses for input. For the full list of events, see Event messages that Image Builder sends.
To learn how to create and customize workflows, including the YAML document format and the available step actions, see Manage build, test, and distribution workflows for Image Builder images.