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 ContainerRecipe construct.

Description of changes

This change implements the ContainerRecipe construct, which is a higher-level construct of CfnContainerRecipe.

Example

const containerRecipe = new imagebuilder.ContainerRecipe(this, 'ContainerRecipe', {
  containerRecipeName: 'test-container-recipe',
  containerRecipeVersion: '1.0.0',
  description: 'A Container Recipe',
  baseImage: imagebuilder.BaseImage.fromEcr(
    this,
    'ECRImage',
    ecr.Repository.fromRepositoryName(this, 'SourceRepository', 'source-repository'),
    'latest',
  ),
  dockerfile: imagebuilder.DockerfileData.fromInline(`
    FROM {{{ imagebuilder:parentImage }}}
    CMD ["echo", "Hello, world!"]
    {{{ imagebuilder:environments }}}
    {{{ imagebuilder:components }}}
  `),
  targetRepository: imagebuilder.Repository.fromEcr(
    ecr.Repository.fromRepositoryName(this, 'TargetRepository', 'imagebuilder-repository'),
  ),
  // Use an AWS-managed component, shared component, and a self-owned component with parameters
  components: [
    {
      component: imagebuilder.AwsManagedComponent.fromAwsManagedComponentName(
        this,
        'update-linux-component',
        'update-linux',
      ),
    },
    {
      component: imagebuilder.Component.fromComponentArn(
        this,
        'ComplianceTestComponent',
        `arn:${this.partition}:imagebuilder:${this.region}:123456789012:component/compliance-test/2025.x.x.x`,
      ),
    },
    {
      component: imagebuilder.Component.fromComponentAttributes(this, 'CustomComponent', {
        componentName: 'custom-component',
      }),
      parameters: {
        CUSTOM_PARAMETER: imagebuilder.ComponentParameterValue.fromString('custom-parameter-value'),
      },
    },
  ],
  workingDirectory: '/var/tmp',
  // The image + block devices to use for the EC2 instance used for building the container image
  instanceImage: imagebuilder.ContainerInstanceImage.fromSsmParameterName(
    this,
    'ContainerInstanceImage',
    '/aws/service/ecs/optimized-ami/amazon-linux-2023/recommended',
  ),
  instanceBlockDevices: [
    {
      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' }),
      }),
    },
  ],
});

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 the p2 label Nov 18, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team November 18, 2025 08:18
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Nov 18, 2025
@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:02
@kumsmrit kumsmrit self-assigned this Nov 18, 2025
@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 18, 2025
@tarunb12 tarunb12 force-pushed the imagebuilder-container-recipe branch from 039ee95 to b4532cb Compare November 19, 2025 04:21
@mergify mergify bot dismissed kumsmrit’s stale review November 19, 2025 04:22

Pull request has been modified.

@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 19, 2025
@tarunb12 tarunb12 force-pushed the imagebuilder-container-recipe branch from b4532cb to ed73d68 Compare November 20, 2025 13:57
@mergify mergify bot dismissed kumsmrit’s stale review November 20, 2025 13:58

Pull request has been modified.

@tarunb12 tarunb12 force-pushed the imagebuilder-container-recipe branch from ed73d68 to 558d237 Compare November 20, 2025 14:34
@mergify mergify bot dismissed kumsmrit’s stale review November 20, 2025 14:34

Pull request has been modified.

@tarunb12 tarunb12 force-pushed the imagebuilder-container-recipe branch from 558d237 to d811b28 Compare November 20, 2025 14:50
@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
@tarunb12 tarunb12 force-pushed the imagebuilder-container-recipe branch 2 times, most recently from 4bb2d3a to 1620275 Compare November 20, 2025 17:35
Copy link
Contributor Author

@tarunb12 tarunb12 left a comment

Choose a reason for hiding this comment

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

Replying to comments

tarunb12

This comment was marked as duplicate.

@kumsmrit kumsmrit added the pr/needs-integration-tests-deployment Requires the PR to deploy the integration test snapshots. label Nov 20, 2025
@tarunb12 tarunb12 force-pushed the imagebuilder-container-recipe branch from 1620275 to 2a5ad9d Compare November 20, 2025 19:50
@tarunb12 tarunb12 force-pushed the imagebuilder-container-recipe branch from 2a5ad9d to 3e832ba Compare November 20, 2025 19:51
@tarunb12 tarunb12 had a problem deploying to deployment-integ-test November 20, 2025 19:51 — with GitHub Actions Failure
@mergify mergify bot dismissed kumsmrit’s stale review November 20, 2025 19:51

Pull request has been modified.

@tarunb12 tarunb12 had a problem deploying to deployment-integ-test November 20, 2025 20:41 — with GitHub Actions Failure
@mergify mergify bot dismissed kumsmrit’s stale review November 20, 2025 20:41

Pull request has been modified.

@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.

@kumsmrit kumsmrit removed pr/request-cli-integ-tests Request CLI integ tests to be run. You will need to review the code and approve the deployment. pr/needs-integration-tests-deployment Requires the PR to deploy the integration test snapshots. labels Nov 20, 2025
@mergify
Copy link
Contributor

mergify bot commented Nov 20, 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 875e0e7 into aws:main Nov 20, 2025
35 of 37 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 20, 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.

3 participants