Skip to main content
In this lesson we walk through EC2 Image Builder with a short demo: what it does, how the main parts fit together, and example component documents you can use to build golden AMIs or managed container images. EC2 Image Builder is AWS’s managed service to build, test, version, and distribute immutable images (AMIs and container images). It automates OS/runtime customization, validation, and multi-account/region publishing — solving the same problems as HashiCorp Packer but as a managed AWS service suitable for CI/CD pipelines and enterprise image governance.
A screenshot of the AWS EC2 Image Builder web page showing a "How it works" diagram that illustrates starting from a base image, customizing and testing it, then distributing the final image. The right side shows a "More resources" panel and the page header/footer and browser tabs are visible.
The golden AMI pattern (pre-baked, versioned images used as immutable infrastructure) is commonly tested on certification exams and is a primary use-case for Image Builder. Architecture — the five key Image Builder components Image Builder assembles several resources into a repeatable pipeline. The five core components are:
  • Image pipelines: orchestration layer that ties together a recipe, infrastructure configuration, distribution settings, and a schedule. Running a pipeline executes the full build → test → publish workflow.
A screenshot of the AWS EC2 Image Builder console showing the "devops-020-240-pipeline" summary. It displays pipeline details (creation time, status = Enabled, ARN and log group links) with an Output images section visible below.
  • Image recipes: define the base image and the ordered set of build and test components to apply. Recipes determine what gets installed and validated on the image.
A screenshot of the AWS EC2 Image Builder console displaying an image recipe named "devops-020-240-recipe" with details like creation time, ARN, base image and platform (Linux). The page also lists build components such as update-linux, devops-020-240-app-dependencies, amazon-cloudwatch-agent-linux, and reboot-linux.
  • Components: reusable YAML documents that perform build or test steps. Build components run commands, transfer files, install packages, and configure services; test components assert correctness and prevent broken images from being published.
A screenshot of the AWS EC2 Image Builder "Components" page listing two components: "devops-020-240-app-dependencies/1.0.0" (BUILD) and "devops-020-240-validation/1.0.0" (TEST), both on Linux. The entries show descriptions and creation times (March 17, 2026).
  • Infrastructure configurations: specify how the build environment is provisioned (instance type, VPC/subnet, IAM instance profile, security groups, logging, key pair, tenancy, and other placement options).
Screenshot of the AWS EC2 Image Builder console on the "Infrastructure configurations" page, showing a table of four infrastructure configurations with their names, descriptions, instance types, and IAM roles. The left-hand navigation menu and top AWS header are also visible.
  • Distribution settings: control where and how the finalized image is published (regions, accounts, AMI tags, KMS keys, license configurations, launch templates, and launch permissions).
A screenshot of the AWS EC2 Image Builder console open to "Distribution settings," showing a table of distribution configuration names. The table lists regions (us-east-1) and creation times, with the left sidebar navigation and top AWS header visible.
Quick reference — Image Builder components summary Build workflow summary
  • Trigger: pipeline can run manually, on a cron schedule, or via EventBridge events.
  • Provision: infrastructure config launches a temporary build instance (e.g., t3.medium) to perform the work.
  • Execute: pipeline runs build components in order, reboots as needed, runs test components, and — if all validations succeed — creates the AMI (or container image) and distributes it per distribution settings.
  • Cleanup: the temporary build instance is terminated after the run; Image Builder does not leave instances running.
Infrastructure configuration creation When you create an infrastructure configuration you choose the name, IAM instance profile (role), instance type, VPC/subnet, security groups, logging options, key pair, tenancy, metadata options, tags, and optional licensing settings.
A screenshot of the AWS Management Console showing the EC2 Image Builder "Create infrastructure configuration" page with fields for Name, Description, IAM role and AWS infrastructure settings. The web UI displays form inputs and dropdowns for configuring an image build.
Image Builder requires both an IAM service role and an EC2 instance profile for the build instance. Ensure those roles include permissions to create/describe AMIs, access S3 (if used), write logs, and any other APIs your components call.
An example infrastructure configuration details view:
A screenshot of the AWS EC2 Image Builder console showing an infrastructure configuration named "devops-020-240-infrastructure" with details like IAM role, ARN, instance type (t3.medium), VPC/subnet, security group, and logs. The page also shows sections for resource tags and other saved resources in the left sidebar.
Components — build and test examples Components are authored as YAML documents. They support phases (build/test) and steps that can ExecuteBash/ExecutePowerShell, run SSM documents, transfer files, download artifacts, or assert values. For AMI builds, steps execute on the temporary EC2 build instance; for container builds they run in the container build environment. Example build component (YAML)
Creating a component in the console is straightforward: pick a name/version/description, select the OS platform, and paste or author the YAML content.
A screenshot of the AWS EC2 Image Builder "Create component" page showing a form to enter component name, version, description, image OS (Linux) and other optional settings. The AWS console header and browser tabs are visible across the top.
Example test (validation) component Tests are critical: if any test step exits non‑zero the pipeline will stop and the AMI will not be published.
Always include test components that verify critical runtime dependencies and configuration. Tests catch broken images before they reach production.
Image recipes and base images A recipe aggregates a base image and an ordered list of components. Base images can be Amazon-managed AMIs, images you own, shared AMIs, Marketplace images, or container bases from ECR/DockerHub. Pin base image and component versions where possible to avoid unexpected changes. When creating a recipe you can:
  • Select base images (AWS-managed, owned, shared, or Marketplace).
  • Add build components (OS updates, agents, packages).
  • Add test components (validation steps).
  • Configure working directory, additional EBS volumes, tags, and other runtime options.
A screenshot of the AWS EC2 Image Builder console displaying an image recipe titled "devops-020-240-recipe | 1.0.0" with summary details (creation time, ARN, base AMI) and a list of build components like update-linux and amazon-cloudwatch-agent-linux. The left sidebar shows navigation items such as Image recipes, Components, and Image pipelines.
A screenshot of the AWS EC2 Image Builder "Create image recipe" page. It shows the Base image selection area with "Select managed images" and "Amazon Linux" chosen, and an "Images owned by me" dropdown showing "No results."
Use Amazon-managed components where appropriate and pin component versions to reduce risk from upstream changes.
A screenshot of the AWS EC2 Image Builder "Create image recipe" page showing the Working directory path set to "/tmp" and sections for Components, Build components, and Test components. The right-hand pane shows Amazon managed components with a "reboot-linux" component selected.
Distribution settings and launch templates Distribution settings define output type (AMI or container image), target regions and accounts, KMS keys, license configurations, launch template associations, and launch permissions (private, share to accounts/OUs, or public). Use launch templates to codify how an AMI should be launched (instance types, network interfaces, user data) so consumers get consistent behavior.
Screenshot of the AWS EC2 Image Builder "Create distribution settings" page showing output type options (Amazon Machine Image selected and Docker image) and form fields for name and description.
Image pipelines — schedules and scanning Pipelines can run manually, on a schedule (cron), or be triggered via EventBridge. You can enable enhanced metadata collection and security scanning during pipeline creation. Typical pipeline run times are ~15–45 minutes depending on package installs and tests.
A screenshot of the AWS EC2 Image Builder console showing the Image pipelines page with one pipeline listed. The pipeline "devops-020-240-pipeline" is enabled (AMI type) with a creation time of March 17, 2026.
Pipeline metadata and security scan options:
A screenshot of the AWS EC2 Image Builder "Create pipeline" console showing options to enable enhanced metadata and security scanning. The lower section displays build schedule settings (Schedule builder, CRON, Manual) with frequency, day and time fields.
Container recipes Image Builder supports container image builds too. You can use ECR images, Docker Hub, or other public images as the base and run components to produce a derived container image — without writing a Dockerfile or running docker build locally.
A screenshot of the AWS Management Console on the EC2 Image Builder "Create image recipe" page. The "Base image" section is visible with "Select managed images" chosen and "Amazon Linux" set as the image OS.
Other capabilities Image Builder also supports:
  • Automated dependency updates and automated builds.
  • Multi-region distribution and cross-account sharing.
  • Lifecycle policies to auto-delete or archive older images and avoid image sprawl.
  • Auto-versioning of published artifacts.
A screenshot of the AWS EC2 Image Builder console on the "Create lifecycle policy" page showing options to activate the policy, choose IAM roles (service defaults or custom), and configure rule scope and selected recipes. The page displays the default IAM execution role name and buttons like "Browse recipes."
Wrapping up EC2 Image Builder streamlines image creation, validation, versioning, and distribution. It is well-suited to implementing golden AMIs and managed container images across accounts and regions. Key best practices:
  • Pin base images and component versions.
  • Include test components to validate images before publication.
  • Configure least-privilege IAM roles for service and instance profiles.
  • Use lifecycle policies to manage image retention and avoid sprawl.
  • Leverage automated schedules and EventBridge triggers for regular builds and security patching.
References and further reading

Watch Video