Skip main navigation
/user/kayd @ devops :~$ cat create-a-new-image-recipe.md

EC2 Image Builder: Create a New Image Recipe EC2 Image Builder: Create a New Image Recipe

QR Code linking to: EC2 Image Builder: Create a New Image Recipe
Karandeep Singh
Karandeep Singh
• 3 minutes

Summary

EC2 Image Builder uses image recipes to define the base image and components that make up your custom AMI. When you need to update packages, add new components, or change the base image, you create a new version of the recipe rather than editing the existing one. This ensures you maintain a versioned history of your AMI configurations.

This guide walks through creating a new recipe version, updating your pipeline to use it, and verifying the resulting AMI.

EC2 Image Builder uses image recipes to define the base image and components that make up your custom AMI. When you need to update packages, add new components, or change the base image, you create a new version of the recipe rather than editing the existing one. This ensures you maintain a versioned history of your AMI configurations.

This guide walks through creating a new recipe version, updating your pipeline to use it, and verifying the resulting AMI.

Prerequisites

  • An existing EC2 Image Builder pipeline with an image recipe
  • IAM permissions for EC2 Image Builder, EC2, and Systems Manager

Step 1: Go to the Existing Image Recipe

Open the EC2 Image Builder console and go to Image recipes. Select the recipe you want to update.

Go to EC2 Image Builder Image Recipes

Step 2: Create a New Version

From the recipe detail page, click Create new version. This pre-fills the configuration from the existing recipe so you only need to change what’s different.

Create a new version of the image recipe

Step 3: Update the Version Number

Increment the version number following semantic versioning (e.g., 1.0.0 to 1.1.0 for minor changes, 2.0.0 for major changes).

Update the image recipe version number

Step 4: Modify Components and Settings

Update any components, build steps, or configuration options as needed. This is where you add new packages, update security patches, or change the base image. Click Create recipe when done.

Update image recipe options and create

Step 5: Verify the New Recipe Version

Confirm the new version appears in the recipe list. Image Builder maintains all previous versions for rollback if needed.

Verify the new recipe version is listed

Step 6: Navigate to the Image Pipeline

Go to Image pipelines and select the pipeline that uses this recipe.

Navigate to EC2 Image Builder pipelines

Step 7: Edit the Pipeline

Click Edit pipeline to update its configuration.

Edit the image pipeline

Step 8: Update the Recipe Version

In the pipeline settings, change the image recipe to the new version you just created. Save your changes.

Update pipeline to use new recipe version

Step 9: Run the Pipeline

Trigger a manual pipeline run to build an AMI from the updated recipe.

Run the image pipeline

Pipeline execution started

Step 10: Monitor the Build Instance

During the build phase, Image Builder launches a temporary EC2 instance to create the AMI. You can see this instance in the EC2 Console > Instances section.

Temporary EC2 instance used for AMI build

0

Step 11: Check Systems Manager Run Command

Image Builder uses AWS Systems Manager to execute build and test commands on the instance. Navigate to Systems Manager > Run Command to monitor progress.

Systems Manager Run Command

1

Step 12: Review Command History

The command history shows all commands that have been executed on the build instance, including component installations and test scripts.

Command history in Systems Manager

2

Step 13: Check the New AMI

Navigate to EC2 Console > AMIs. The new AMI will appear with a status of “Pending” during creation.

New AMI being created in EC2 Console

3

Step 14: Wait for the Testing Phase

Once the AMI becomes “Available”, the pipeline enters the Testing phase. Image Builder runs any test components defined in the recipe to validate the AMI.

Pipeline enters testing phase

Testing phase in progress

4

Step 15: Distribution

After testing completes successfully, the pipeline moves to the linux-distros/">Distribution phase. The AMI is distributed according to your distribution settings (target regions, shared accounts, etc.) and the pipeline status changes to “Available”.

Distribution phase completed

Pipeline completed successfully

The entire build-test-distribute cycle typically takes 20-30 minutes depending on instance type and the number of components being installed.

Similar Articles

More from devops