Skip to content

Conversation

@tarunb12
Copy link
Contributor

@tarunb12 tarunb12 commented Nov 18, 2025

Issue

aws/aws-cdk-rfcs#789

Reason for this change

This change adds a new alpha module for EC2 Image Builder L2 Constructs (@aws-cdk/aws-imagebuilder-alpha), as outlined in aws/aws-cdk-rfcs#789. This PR specifically implements the ImageRecipe construct.

Description of changes

This change implements the ImageRecipe construct, which is a higher-level construct of CfnImageRecipe.

Example

const userData = ec2.UserData.forLinux();
userData.addS3DownloadCommand({
  bucket: s3.Bucket.fromBucketName(this, 'Bucket', `test-bucket-${this.account}`),
  bucketKey: 'test-key',
  localFile: 's3-executable.sh',
});
userData.addExecuteFileCommand({ filePath: 's3-executable.sh' });
userData.addCommands('User Data complete!');

const imageRecipe = new imagebuilder.ImageRecipe(this, 'ImageRecipe', {
  imageRecipeName: 'test-image-recipe',
  imageRecipeVersion: '1.0.0',
  description: 'An Image Recipe',
  // Use an AL2023 base image
  baseImage: imagebuilder.BaseImage.fromSsmParameterName(
    this,
    'MachineImage',
    '/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64',
  ),
  // Use an AWS-managed component, shared component, self-owned component with parameters, and marketplace component
  components: [
    {
      component: imagebuilder.AwsManagedComponent.updateOS(this, 'UpdateOS', {
        platform: imagebuilder.Platform.Linux,
      }),
    },
    {
      component: imagebuilder.Component.fromComponentArn(
        this,
        'ComplianceTestComponent',
        `arn:${this.partition}:imagebuilder:${this.region}:123456789012:component/compliance-test/2025.x.x.x`,
      ),
    },
    {
      component: imagebuilder.AwsMarketplaceComponent.fromAwsMarketplaceComponentAttributes(
        this,
        'MarketplaceComponent',
        {
          name: 'marketplace-component-name',
          marketplaceProductId: '12345678-1234-1234-1234-123456789012',
        },
      ),
    },
    {
      component: imagebuilder.Component.fromComponentAttributes(this, 'CustomComponent', {
        componentName: 'custom-component',
      }),
      parameters: {
        CUSTOM_PARAMETER_KEY: imagebuilder.ComponentParameterValue.fromString('custom-parameter-value'),
      },
    },
  ],
  workingDirectory: '/var/tmp',
  // Optional - retain the SSM agent after the build, and apply custom userdata
  uninstallSsmAgentAfterBuild: false,
  userDataOverride: userData,
  // Optional - attach additional block device to the build instance
  blockDevices: [
    {
      deviceName: '/dev/sda1',
      mappingEnabled: true,
      volume: ec2.BlockDeviceVolume.ebs(50, {
        deleteOnTermination: true,
        iops: 1000,
        volumeType: ec2.EbsDeviceVolumeType.GP3,
        throughput: 1000,
        encrypted: true,
        kmsKey: kms.Key.fromLookup(this, 'VolumeKey', { aliasName: 'alias/volume-encryption-key' }),
      }),
    },
  ],
  // Optional - specify tags to apply to the output AMI
  amiTags: {
    Environment: 'production',
  },
});

Describe any new or updated permissions being added

N/A - new L2 construct in alpha module

Description of how you validated changes

Validated with unit tests and integration tests. Manually verified generated CFN templates as well.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 labels Nov 18, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team November 18, 2025 08:21
@aws-cdk-automation aws-cdk-automation added the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Nov 18, 2025
@tarunb12 tarunb12 marked this pull request as ready for review November 18, 2025 09:01
@ozelalisen ozelalisen self-assigned this Nov 18, 2025
Copy link
Member

@ozelalisen ozelalisen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for considering patterns from previous PRs, left first round of comments

@tarunb12 tarunb12 force-pushed the imagebuilder-image-recipe branch from 56b4365 to f41878c Compare November 19, 2025 03:23
@mergify mergify bot dismissed ozelalisen’s stale review November 19, 2025 03:23

Pull request has been modified.

@tarunb12 tarunb12 force-pushed the imagebuilder-image-recipe branch 2 times, most recently from 336df49 to aef71d7 Compare November 19, 2025 03:36
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 19, 2025
@tarunb12 tarunb12 force-pushed the imagebuilder-image-recipe branch from aef71d7 to 7ca9300 Compare November 19, 2025 04:23
@tarunb12 tarunb12 force-pushed the imagebuilder-image-recipe branch 3 times, most recently from 67dc785 to c40374a Compare November 20, 2025 14:40
@kumsmrit kumsmrit added the pr/request-cli-integ-tests Request CLI integ tests to be run. You will need to review the code and approve the deployment. label Nov 20, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 20, 2025
@tarunb12 tarunb12 force-pushed the imagebuilder-image-recipe branch from c40374a to 13ffadb Compare November 20, 2025 17:18
@mergify mergify bot dismissed kumsmrit’s stale review November 20, 2025 17:18

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 20, 2025
@tarunb12 tarunb12 force-pushed the imagebuilder-image-recipe branch from 13ffadb to e0570c3 Compare November 20, 2025 20:02
@kumsmrit kumsmrit added the pr/needs-integration-tests-deployment Requires the PR to deploy the integration test snapshots. label Nov 21, 2025
@kumsmrit kumsmrit had a problem deploying to deployment-integ-test November 21, 2025 13:04 — with GitHub Actions Failure
@kumsmrit kumsmrit removed the pr/needs-integration-tests-deployment Requires the PR to deploy the integration test snapshots. label Nov 21, 2025
@tarunb12 tarunb12 force-pushed the imagebuilder-image-recipe branch from c0a198d to 5ca5297 Compare November 21, 2025 14:42
@mergify mergify bot dismissed kumsmrit’s stale review November 21, 2025 14:42

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 21, 2025
@aws-cdk-automation
Copy link
Collaborator

➡️ PR build request submitted to test-main-pipeline ⬅️

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

Copy link
Contributor

@kumsmrit kumsmrit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing all the comments

@mergify
Copy link
Contributor

mergify bot commented Nov 21, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@kumsmrit kumsmrit removed the pr/request-cli-integ-tests Request CLI integ tests to be run. You will need to review the code and approve the deployment. label Nov 21, 2025
@mergify
Copy link
Contributor

mergify bot commented Nov 21, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 4361f8b into aws:main Nov 21, 2025
23 of 25 checks passed
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 21, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants