Skip to content

Conversation

@tarunb12
Copy link
Contributor

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

Description of changes

This change implements the DistributionConfiguration construct, which is a higher-level construct of CfnDistributionConfiguration.

Example

const distributionConfiguration = new imagebuilder.DistributionConfiguration(this, 'DistributionConfiguration', {
  distributionConfigurationName: 'test-distribution-configuration',
  description: 'A Distribution Configuration',
  amiDistributions: [
    {
      // Distribute AMI to us-east-2 and publish the AMI ID to an SSM parameter
      region: 'us-east-2',
      ssmParameters: [
        {
          parameter: ssm.StringParameter.fromStringParameterAttributes(this, 'CrossRegionParameter', {
            parameterName: '/imagebuilder/ami',
            forceDynamicReference: true
          })
        }
      ]
    }
  ]
});

// For AMI-based image builds - add an AMI distribution in the current region
distributionConfiguration.addAmiDistributions({
  amiName: 'imagebuilder-{{ imagebuilder:buildDate }}',
  amiDescription: 'Build AMI',
  amiKmsKey: kms.Key.fromLookup(this, 'ComponentKey', { aliasName: 'alias/distribution-encryption-key' }),
  // Copy the AMI to different accounts
  amiTargetAccountIds: ['123456789012', '098765432109'],
  // Add launch permissions on the AMI
  amiLaunchPermission: {
    organizationArns: [
      this.formatArn({ region: '', service: 'organizations', resource: 'organization', resourceName: 'o-1234567abc' })
    ],
    organizationalUnitArns: [
      this.formatArn({
        region: '',
        service: 'organizations',
        resource: 'ou',
        resourceName: 'o-1234567abc/ou-a123-b4567890'
      })
    ],
    userGroups: ['all'],
    userIds: ['234567890123']
  },
  // Attach tags to the AMI
  amiTags: {
    Environment: 'production',
    Version: '{{ imagebuilder:buildVersion }}'
  },
  // Optional - publish the distributed AMI ID to an SSM parameter
  ssmParameters: [
    {
      parameter: ssm.StringParameter.fromStringParameterAttributes(this, 'Parameter', {
        parameterName: '/imagebuilder/ami',
        forceDynamicReference: true
      })
    },
    {
      amiAccount: '098765432109',
      dataType: ssm.ParameterDataType.TEXT,
      parameter: ssm.StringParameter.fromStringParameterAttributes(this, 'CrossAccountParameter', {
        parameterName: 'imagebuilder-prod-ami',
        forceDynamicReference: true
      })
    }
  ],
  // Optional - create a new launch template version with the distributed AMI ID
  launchTemplates: [
    {
      launchTemplate: ec2.LaunchTemplate.fromLaunchTemplateAttributes(this, 'LaunchTemplate', {
        launchTemplateName: 'imagebuilder-ami'
      }),
      setDefaultVersion: true
    },
    {
      accountId: '098765432109',
      launchTemplate: ec2.LaunchTemplate.fromLaunchTemplateAttributes(this, 'CrossAccountLaunchTemplate', {
        launchTemplateName: 'imagebuilder-cross-account-ami'
      }),
      setDefaultVersion: true
    }
  ],
  // Optional - enable Fast Launch on an imported launch template
  fastLaunchConfigurations: [
    {
      enabled: true,
      launchTemplate: ec2.LaunchTemplate.fromLaunchTemplateAttributes(this, 'FastLaunchLT', {
        launchTemplateName: 'fast-launch-lt'
      }),
      maxParallelLaunches: 10,
      targetSnapshotCount: 2
    }
  ],
  // Optional - license configurations to apply to the AMI
  licenseConfigurationArns: [
    'arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-abcdefghijklmnopqrstuvwxyz'
  ]
});

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

@aws-cdk-automation aws-cdk-automation requested a review from a team November 11, 2025 05:22
@github-actions github-actions bot added p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Nov 11, 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 11, 2025
@tarunb12 tarunb12 force-pushed the imagebuilder-distribution branch 3 times, most recently from 1de77fb to cfde029 Compare November 11, 2025 06:41
@tarunb12 tarunb12 marked this pull request as ready for review November 11, 2025 09:30
@kumsmrit kumsmrit self-assigned this Nov 11, 2025
@ozelalisen ozelalisen changed the title feat(imagebuilder): add support for EC2 Image Builder L2 Constructs - Distribution Configuration feat(imagebuilder-alpha): add support for Distribution Configuration Construct Nov 13, 2025
@tarunb12 tarunb12 force-pushed the imagebuilder-distribution branch from cfde029 to 9a9c664 Compare November 13, 2025 21:49
@mergify mergify bot dismissed kumsmrit’s stale review November 13, 2025 21:49

Pull request has been modified.

@tarunb12 tarunb12 force-pushed the imagebuilder-distribution branch from 1fba748 to 5d3ff75 Compare November 13, 2025 21:51
@tarunb12 tarunb12 force-pushed the imagebuilder-distribution branch from 722fa15 to bb3a318 Compare November 14, 2025 18:17
@mergify mergify bot dismissed kumsmrit’s stale review November 14, 2025 18:18

Pull request has been modified.

@tarunb12 tarunb12 force-pushed the imagebuilder-distribution branch from bb3a318 to 5f7848e Compare November 14, 2025 18:20
@kumsmrit
Copy link
Contributor

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2025

refresh

✅ Pull request refreshed

@kumsmrit
Copy link
Contributor

@Mergifyio queue

@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2025

queue

🟠 Waiting for conditions to match

  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default-merge]
      • label~=no-squash
      • any of:
        • -label~=pr/needs-integration-tests-deployment
        • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
      • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
      • #approved-reviews-by>=1
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • -approved-reviews-by~=author
      • -closed
      • -label~=(blocked|do-not-merge)
      • -merged
      • -title~=(WIP|wip)
      • check-success=build
      • check-success=validate-pr
      • any of: [🛡 GitHub branch protection]
        • check-success = validate-pr
        • check-neutral = validate-pr
        • check-skipped = validate-pr
      • any of: [🛡 GitHub branch protection]
        • check-success = build
        • check-neutral = build
        • check-skipped = build
    • all of: [📌 queue conditions of queue default-squash]
      • any of:
        • -label~=pr/needs-integration-tests-deployment
        • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
      • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
      • #approved-reviews-by>=1
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • -approved-reviews-by~=author
      • -closed
      • -label~=(blocked|do-not-merge|no-squash|priority-pr)
      • -merged
      • -title~=(WIP|wip)
      • base!=release
      • check-success=build
      • check-success=validate-pr
      • any of: [🛡 GitHub branch protection]
        • check-success = validate-pr
        • check-neutral = validate-pr
        • check-skipped = validate-pr
      • any of: [🛡 GitHub branch protection]
        • check-success = build
        • check-neutral = build
        • check-skipped = build
    • all of: [📌 queue conditions of queue priority-squash]
      • label~=priority-pr
      • any of:
        • -label~=pr/needs-integration-tests-deployment
        • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
      • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
      • #approved-reviews-by>=1
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • -approved-reviews-by~=author
      • -closed
      • -label~=(blocked|do-not-merge|no-squash)
      • -merged
      • -title~=(WIP|wip)
      • base!=release
      • check-success=build
      • check-success=validate-pr
      • any of: [🛡 GitHub branch protection]
        • check-success = validate-pr
        • check-neutral = validate-pr
        • check-skipped = validate-pr
      • any of: [🛡 GitHub branch protection]
        • check-success = build
        • check-neutral = build
        • check-skipped = build
  • -closed [📌 queue requirement]
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of: [📌 queue -> configuration change requirements]
    • -mergify-configuration-changed
    • check-success = Configuration changed

@kumsmrit kumsmrit removed the pr/needs-integration-tests-deployment Requires the PR to deploy the integration test snapshots. label Nov 18, 2025
@kumsmrit
Copy link
Contributor

@Mergifyio queue

@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2025

queue

🟠 Waiting for conditions to match

  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default-merge]
      • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
      • #approved-reviews-by>=1
      • check-success=build
      • label~=no-squash
      • any of: [🛡 GitHub branch protection]
        • check-neutral = build
        • check-skipped = build
        • check-success = build
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • -approved-reviews-by~=author
      • -closed
      • -label~=(blocked|do-not-merge)
      • -merged
      • -title~=(WIP|wip)
      • check-success=validate-pr
      • any of:
        • -label~=pr/needs-integration-tests-deployment
        • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
      • any of: [🛡 GitHub branch protection]
        • check-success = validate-pr
        • check-neutral = validate-pr
        • check-skipped = validate-pr
    • all of: [📌 queue conditions of queue default-squash]
      • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
      • #approved-reviews-by>=1
      • check-success=build
      • any of: [🛡 GitHub branch protection]
        • check-neutral = build
        • check-skipped = build
        • check-success = build
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • -approved-reviews-by~=author
      • -closed
      • -label~=(blocked|do-not-merge|no-squash|priority-pr)
      • -merged
      • -title~=(WIP|wip)
      • base!=release
      • check-success=validate-pr
      • any of:
        • -label~=pr/needs-integration-tests-deployment
        • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
      • any of: [🛡 GitHub branch protection]
        • check-success = validate-pr
        • check-neutral = validate-pr
        • check-skipped = validate-pr
    • all of: [📌 queue conditions of queue priority-squash]
      • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
      • #approved-reviews-by>=1
      • check-success=build
      • label~=priority-pr
      • any of: [🛡 GitHub branch protection]
        • check-neutral = build
        • check-skipped = build
        • check-success = build
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • -approved-reviews-by~=author
      • -closed
      • -label~=(blocked|do-not-merge|no-squash)
      • -merged
      • -title~=(WIP|wip)
      • base!=release
      • check-success=validate-pr
      • any of:
        • -label~=pr/needs-integration-tests-deployment
        • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
      • any of: [🛡 GitHub branch protection]
        • check-success = validate-pr
        • check-neutral = validate-pr
        • check-skipped = validate-pr
  • -closed [📌 queue requirement]
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of: [📌 queue -> configuration change requirements]
    • -mergify-configuration-changed
    • check-success = Configuration changed

@mergify mergify bot dismissed stale reviews from kumsmrit and gasolima November 18, 2025 12:33

Pull request has been modified.

@kumsmrit kumsmrit removed the pr/requires-two-approvers This PR is critical (e.g., security, broadly-impacting) and requires 2 approvers to be merged. label Nov 18, 2025
@kumsmrit
Copy link
Contributor

@Mergifyio queue

@kumsmrit
Copy link
Contributor

@Mergifyio refresh

@kumsmrit
Copy link
Contributor

@Mergifyio queue

@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2025

queue

🟠 Waiting for conditions to match

  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default-merge]
      • check-success=build
      • label~=no-squash
      • any of: [🛡 GitHub branch protection]
        • check-neutral = build
        • check-skipped = build
        • check-success = build
      • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
      • #approved-reviews-by>=1
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • -approved-reviews-by~=author
      • -closed
      • -label~=(blocked|do-not-merge)
      • -merged
      • -title~=(WIP|wip)
      • check-success=validate-pr
      • any of:
        • -label~=pr/needs-integration-tests-deployment
        • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
      • any of: [🛡 GitHub branch protection]
        • check-success = validate-pr
        • check-neutral = validate-pr
        • check-skipped = validate-pr
    • all of: [📌 queue conditions of queue default-squash]
      • check-success=build
      • any of: [🛡 GitHub branch protection]
        • check-neutral = build
        • check-skipped = build
        • check-success = build
      • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
      • #approved-reviews-by>=1
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • -approved-reviews-by~=author
      • -closed
      • -label~=(blocked|do-not-merge|no-squash|priority-pr)
      • -merged
      • -title~=(WIP|wip)
      • base!=release
      • check-success=validate-pr
      • any of:
        • -label~=pr/needs-integration-tests-deployment
        • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
      • any of: [🛡 GitHub branch protection]
        • check-success = validate-pr
        • check-neutral = validate-pr
        • check-skipped = validate-pr
    • all of: [📌 queue conditions of queue priority-squash]
      • check-success=build
      • label~=priority-pr
      • any of: [🛡 GitHub branch protection]
        • check-neutral = build
        • check-skipped = build
        • check-success = build
      • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
      • #approved-reviews-by>=1
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • -approved-reviews-by~=author
      • -closed
      • -label~=(blocked|do-not-merge|no-squash)
      • -merged
      • -title~=(WIP|wip)
      • base!=release
      • check-success=validate-pr
      • any of:
        • -label~=pr/needs-integration-tests-deployment
        • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
      • any of: [🛡 GitHub branch protection]
        • check-success = validate-pr
        • check-neutral = validate-pr
        • check-skipped = validate-pr
  • -closed [📌 queue requirement]
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of: [📌 queue -> configuration change requirements]
    • -mergify-configuration-changed
    • check-success = Configuration changed

@kumsmrit
Copy link
Contributor

@Mergifyio queue

@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2025

queue

🛑 There are no queue conditions matching

There are queue conditions defined in the configuration, but none matches. The pull request has not been embarked.

Details:

  • Queue default-merge:
  • -closed
  • -merged
  • label~=no-squash
  • #approved-reviews-by>=1
  • #changes-requested-reviews-by=0
  • -approved-reviews-by~=author
  • -label~=(blocked|do-not-merge)
  • -title~=(WIP|wip)
  • check-success=build
  • check-success=validate-pr
  • any of:
    • -label~=pr/needs-integration-tests-deployment
    • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
  • Queue priority-squash:
  • -closed
  • -merged
  • label~=priority-pr
  • #approved-reviews-by>=1
  • #changes-requested-reviews-by=0
  • -approved-reviews-by~=author
  • -label~=(blocked|do-not-merge|no-squash)
  • -title~=(WIP|wip)
  • base!=release
  • check-success=build
  • check-success=validate-pr
  • any of:
    • -label~=pr/needs-integration-tests-deployment
    • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)
  • Queue default-squash:
  • -closed
  • -merged
  • #approved-reviews-by>=1
  • #changes-requested-reviews-by=0
  • -approved-reviews-by~=author
  • -label~=(blocked|do-not-merge|no-squash|priority-pr)
  • -title~=(WIP|wip)
  • base!=release
  • check-success=build
  • check-success=validate-pr
  • any of:
    • -label~=pr/needs-integration-tests-deployment
    • check-success=Deploy integration test snapshots (requires pr/needs-integration-tests-deployment label)

@ozelalisen
Copy link
Member

@Mergifyio requeue

@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2025

requeue

☑️ This pull request is already queued

@ozelalisen
Copy link
Member

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2025

update

✅ Branch has been successfully updated

@mergify
Copy link
Contributor

mergify bot commented Nov 18, 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 c36f43d into aws:main Nov 18, 2025
20 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 18, 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.

5 participants