class DistributionConfiguration (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.ImageBuilder.Alpha.DistributionConfiguration |
Go | github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2#DistributionConfiguration |
Java | software.amazon.awscdk.services.imagebuilder.alpha.DistributionConfiguration |
Python | aws_cdk.aws_imagebuilder_alpha.DistributionConfiguration |
TypeScript (source) | @aws-cdk/aws-imagebuilder-alpha ยป DistributionConfiguration |
Implements
IConstruct, IDependable, IResource, IEnvironment, IDistribution
Represents an EC2 Image Builder Distribution Configuration.
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'
})
],
isPublicUserGroup: true,
accountIds: ['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', {
launchTemplateId: 'lt-1234'
}),
setDefaultVersion: true
},
{
accountId: '123456789012',
launchTemplate: ec2.LaunchTemplate.fromLaunchTemplateAttributes(this, 'CrossAccountLaunchTemplate', {
launchTemplateId: 'lt-5678'
}),
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'
]
});
Initializer
new DistributionConfiguration(scope: Construct, id: string, props?: DistributionConfigurationProps)
Parameters
- scope
Construct - id
string - props
DistributionConfiguration Props
Construct Props
| Name | Type | Description |
|---|---|---|
| ami | Ami[] | The list of target regions and associated AMI distribution settings where the built AMI will be distributed. |
| container | Container[] | The list of target regions and associated container distribution settings where the built container will be distributed. |
| description? | string | The description of the distribution configuration. |
| distribution | string | The name of the distribution configuration. |
| tags? | { [string]: string } | The tags to apply to the distribution configuration. |
amiDistributions?
Type:
Ami[]
(optional, default: None if container distributions are provided. Otherwise, at least one AMI or container distribution must
be provided)
The list of target regions and associated AMI distribution settings where the built AMI will be distributed.
AMI
distributions may also be added with the addAmiDistributions method.
containerDistributions?
Type:
Container[]
(optional, default: None if AMI distributions are provided. Otherwise, at least one AMI or container distribution must be
provided)
The list of target regions and associated container distribution settings where the built container will be distributed.
Container distributions may also be added with the addContainerDistributions method.
description?
Type:
string
(optional, default: None)
The description of the distribution configuration.
distributionConfigurationName?
Type:
string
(optional, default: A name is generated)
The name of the distribution configuration.
tags?
Type:
{ [string]: string }
(optional, default: None)
The tags to apply to the distribution configuration.
Properties
| Name | Type | Description |
|---|---|---|
| distribution | string | The ARN of the distribution configuration. |
| distribution | string | The name of the distribution configuration. |
| env | Resource | The environment this resource belongs to. |
| node | Node | The tree node. |
| stack | Stack | The stack in which this resource is defined. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
distributionConfigurationArn
Type:
string
The ARN of the distribution configuration.
distributionConfigurationName
Type:
string
The name of the distribution configuration.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| add | Adds AMI distribution settings to the distribution configuration. |
| add | Adds container distribution settings to the distribution configuration. |
| apply | Apply the given removal policy to this resource. |
| grant(grantee, ...actions) | Grant custom actions to the given grantee for the distribution configuration. |
| grant | Grant read permissions to the given grantee for the distribution configuration. |
| to | Returns a string representation of this construct. |
| static from | Import an existing distribution configuration given its ARN. |
| static from | Import an existing distribution configuration given its name. |
| static is | Return whether the given object is a DistributionConfiguration. |
addAmiDistributions(...amiDistributions)
public addAmiDistributions(...amiDistributions: AmiDistribution[]): void
Parameters
- amiDistributions
Amiโ The list of AMI distribution settings to apply.Distribution
Adds AMI distribution settings to the distribution configuration.
addContainerDistributions(...containerDistributions)
public addContainerDistributions(...containerDistributions: ContainerDistribution[]): void
Parameters
- containerDistributions
Containerโ The list of container distribution settings to apply.Distribution
Adds container distribution settings to the distribution configuration.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantableโ The principal. - actions
stringโ The list of actions.
Returns
Grant custom actions to the given grantee for the distribution configuration.
grantRead(grantee)
public grantRead(grantee: IGrantable): Grant
Parameters
- grantee
IGrantableโ The principal.
Returns
Grant read permissions to the given grantee for the distribution configuration.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromDistributionConfigurationArn(scope, id, distributionConfigurationArn)
public static fromDistributionConfigurationArn(scope: Construct, id: string, distributionConfigurationArn: string): IDistributionConfiguration
Parameters
- scope
Construct - id
string - distributionConfigurationArn
string
Returns
Import an existing distribution configuration given its ARN.
static fromDistributionConfigurationName(scope, id, distributionConfigurationName)
public static fromDistributionConfigurationName(scope: Construct, id: string, distributionConfigurationName: string): IDistributionConfiguration
Parameters
- scope
Construct - id
string - distributionConfigurationName
string
Returns
Import an existing distribution configuration given its name.
The provided name must be normalized by converting all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens.
static isDistributionConfiguration(x)
public static isDistributionConfiguration(x: any): boolean
Parameters
- x
any
Returns
boolean
Return whether the given object is a DistributionConfiguration.

.NET
Go
Java
Python
TypeScript (