Skip to content
v2.273.0

Experimental

@aws-cdk/aws-imagebuilder-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

DistributionConfiguration L2 construct ​

Represents an EC2 Image Builder Distribution Configuration.

Example ​

ts
const infrastructureConfiguration = new imagebuilder.InfrastructureConfiguration(this, 'Infrastructure', {
  infrastructureConfigurationName: 'production-infrastructure',
  instanceTypes: [
    ec2.InstanceType.of(ec2.InstanceClass.COMPUTE7_INTEL, ec2.InstanceSize.LARGE)
  ],
  vpc: vpc,
  subnetSelection: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS }
});

const distributionConfiguration = new imagebuilder.DistributionConfiguration(this, 'Distribution');
distributionConfiguration.addAmiDistributions({
  amiName: 'production-ami-{{ imagebuilder:buildDate }}',
  amiTargetAccountIds: ['123456789012', '098765432109']
});

const productionPipeline = new imagebuilder.ImagePipeline(this, 'ProductionPipeline', {
  recipe: exampleImageRecipe,
  infrastructureConfiguration: infrastructureConfiguration,
  distributionConfiguration: distributionConfiguration
});
python
infrastructure_configuration = imagebuilder.InfrastructureConfiguration(self, "Infrastructure",
    infrastructure_configuration_name="production-infrastructure",
    instance_types=[
        ec2.InstanceType.of(ec2.InstanceClass.COMPUTE7_INTEL, ec2.InstanceSize.LARGE)
    ],
    vpc=vpc,
    subnet_selection=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS)
)

distribution_configuration = imagebuilder.DistributionConfiguration(self, "Distribution")
distribution_configuration.add_ami_distributions(
    ami_name="production-ami-{{ imagebuilder:buildDate }}",
    ami_target_account_ids=["123456789012", "098765432109"]
)

production_pipeline = imagebuilder.ImagePipeline(self, "ProductionPipeline",
    recipe=example_image_recipe,
    infrastructure_configuration=infrastructure_configuration,
    distribution_configuration=distribution_configuration
)
java
InfrastructureConfiguration infrastructureConfiguration = InfrastructureConfiguration.Builder.create(this, "Infrastructure")
        .infrastructureConfigurationName("production-infrastructure")
        .instanceTypes(List.of(InstanceType.of(InstanceClass.COMPUTE7_INTEL, InstanceSize.LARGE)))
        .vpc(vpc)
        .subnetSelection(SubnetSelection.builder().subnetType(SubnetType.PRIVATE_WITH_EGRESS).build())
        .build();

DistributionConfiguration distributionConfiguration = new DistributionConfiguration(this, "Distribution");
distributionConfiguration.addAmiDistributions(AmiDistribution.builder()
        .amiName("production-ami-{{ imagebuilder:buildDate }}")
        .amiTargetAccountIds(List.of("123456789012", "098765432109"))
        .build());

ImagePipeline productionPipeline = ImagePipeline.Builder.create(this, "ProductionPipeline")
        .recipe(exampleImageRecipe)
        .infrastructureConfiguration(infrastructureConfiguration)
        .distributionConfiguration(distributionConfiguration)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var infrastructureConfiguration = new InfrastructureConfiguration(this, "Infrastructure", new InfrastructureConfigurationProps {
    InfrastructureConfigurationName = "production-infrastructure",
    InstanceTypes = new [] { InstanceType.Of(InstanceClass.COMPUTE7_INTEL, InstanceSize.LARGE) },
    Vpc = vpc,
    SubnetSelection = new SubnetSelection { SubnetType = SubnetType.PRIVATE_WITH_EGRESS }
});

var distributionConfiguration = new DistributionConfiguration(this, "Distribution");
distributionConfiguration.AddAmiDistributions(new AmiDistribution {
    AmiName = "production-ami-{{ imagebuilder:buildDate }}",
    AmiTargetAccountIds = new [] { "123456789012", "098765432109" }
});

var productionPipeline = new ImagePipeline(this, "ProductionPipeline", new ImagePipelineProps {
    Recipe = exampleImageRecipe,
    InfrastructureConfiguration = infrastructureConfiguration,
    DistributionConfiguration = distributionConfiguration
});
go
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
infrastructureConfiguration := imagebuilder.NewInfrastructureConfiguration(this, jsii.String("Infrastructure"), &InfrastructureConfigurationProps{
	InfrastructureConfigurationName: jsii.String("production-infrastructure"),
	InstanceTypes: []InstanceType{
		ec2.InstanceType_*Of(ec2.InstanceClass_COMPUTE7_INTEL, ec2.InstanceSize_LARGE),
	},
	Vpc: vpc,
	SubnetSelection: &SubnetSelection{
		SubnetType: ec2.SubnetType_PRIVATE_WITH_EGRESS,
	},
})

distributionConfiguration := imagebuilder.NewDistributionConfiguration(this, jsii.String("Distribution"))
distributionConfiguration.AddAmiDistributions(&AmiDistribution{
	AmiName: jsii.String("production-ami-{{ imagebuilder:buildDate }}"),
	AmiTargetAccountIds: []*string{
		jsii.String("123456789012"),
		jsii.String("098765432109"),
	},
})

productionPipeline := imagebuilder.NewImagePipeline(this, jsii.String("ProductionPipeline"), &ImagePipelineProps{
	Recipe: exampleImageRecipe,
	InfrastructureConfiguration: infrastructureConfiguration,
	DistributionConfiguration: distributionConfiguration,
})

Initializer ​

ts
new DistributionConfiguration(scope: Construct, id: string, props?: DistributionConfigurationProps)
python
DistributionConfiguration(scope: Construct, id: str, props: typing.Optional[DistributionConfigurationProps] = None)
java
new DistributionConfiguration(Construct scope, String id, DistributionConfigurationProps props)
csharp
new DistributionConfiguration(Construct scope, string id, DistributionConfigurationProps? props = null)
go
NewDistributionConfiguration(Scope Construct, Id *string, Props DistributionConfigurationProps)

Construct Props ​

amiDistributionsAmiDistribution[]ami_distributionstyping.List[AmiDistribution]amiDistributionsList<AmiDistribution>AmiDistributionsAmiDistribution[]AmiDistributions*[]AmiDistribution= None if container distributions …#
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.

default

Default: None if container distributions are provided. Otherwise, at least one AMI or container distribution must be provided

containerDistributionsContainerDistribution[]container_distributionstyping.List[ContainerDistribution]containerDistributionsList<ContainerDistribution>ContainerDistributionsContainerDistribution[]ContainerDistributions*[]ContainerDistribution= None if AMI distributions are pr…#
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.

default

Default: None if AMI distributions are provided. Otherwise, at least one AMI or container distribution must be provided

descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= None#
The description of the distribution configuration.
distributionConfigurationNamestringdistribution_configuration_namestrdistributionConfigurationNameStringDistributionConfigurationNamestringDistributionConfigurationName*string= A name is generated#
The name of the distribution configuration.
tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string= None#
The tags to apply to the distribution configuration.

Properties ​

distributionConfigurationArnstringdistribution_configuration_arnstrdistributionConfigurationArnStringDistributionConfigurationArnstringDistributionConfigurationArn*stringrequired#
The ARN of the distribution configuration.
distributionConfigurationNamestringdistribution_configuration_namestrdistributionConfigurationNameStringDistributionConfigurationNamestringDistributionConfigurationName*stringrequired#
The name of the distribution configuration.
The environment this resource belongs to.
notes

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.

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.

Methods ​

addAmiDistributions(...amiDistributions: AmiDistribution[]): voiddef add_ami_distributions(self, ami_distributions: AmiDistribution) -> Nonepublic void addAmiDistributions(AmiDistribution amiDistributions)public void AddAmiDistributions(AmiDistribution amiDistributions)func AddAmiDistributions(AmiDistributions AmiDistribution)#
Adds AMI distribution settings to the distribution configuration.
1 parameter

Parameters

  • amiDistributionsami_distributionsamiDistributionsamiDistributionsAmiDistributions — The list of AMI distribution settings to apply.
addContainerDistributions(...containerDistributions: ContainerDistribution[]): voiddef add_container_distributions(self, container_distributions: ContainerDistribution) -> Nonepublic void addContainerDistributions(ContainerDistribution containerDistributions)public void AddContainerDistributions(ContainerDistribution containerDistributions)func AddContainerDistributions(ContainerDistributions ContainerDistribution)#
Adds container distribution settings to the distribution configuration.
1 parameter

Parameters

  • containerDistributionscontainer_distributionscontainerDistributionscontainerDistributionsContainerDistributions — The list of container distribution settings to apply.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

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

fromDistributionConfigurationArn(scope: Construct, id: string, distributionConfigurationArn: string): IDistributionConfiguration@staticmethod def from_distribution_configuration_arn(scope: Construct, id: str, distribution_configuration_arn: str) -> IDistributionConfigurationpublic static IDistributionConfiguration fromDistributionConfigurationArn(Construct scope, String id, String distributionConfigurationArn)public static IDistributionConfiguration FromDistributionConfigurationArn(Construct scope, string id, string distributionConfigurationArn)func FromDistributionConfigurationArn(Scope Construct, Id *string, DistributionConfigurationArn *string) IDistributionConfigurationstatic#
Import an existing distribution configuration given its ARN.
fromDistributionConfigurationName(scope: Construct, id: string, distributionConfigurationName: string): IDistributionConfiguration@staticmethod def from_distribution_configuration_name(scope: Construct, id: str, distribution_configuration_name: str) -> IDistributionConfigurationpublic static IDistributionConfiguration fromDistributionConfigurationName(Construct scope, String id, String distributionConfigurationName)public static IDistributionConfiguration FromDistributionConfigurationName(Construct scope, string id, string distributionConfigurationName)func FromDistributionConfigurationName(Scope Construct, Id *string, DistributionConfigurationName *string) IDistributionConfigurationstatic#
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.

grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#
Grant custom actions to the given grantee for the distribution configuration [disable-awslint:no-grants].
2 parameters

Parameters

  • granteegranteegranteegranteeGrantee — The principal.
  • actionsactionsactionsactionsActions — The list of actions.
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#
Grant read permissions to the given grantee for the distribution configuration [disable-awslint:no-grants].
1 parameter

Parameters

  • granteegranteegranteegranteeGrantee — The principal.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isDistributionConfiguration(x: any): boolean@staticmethod def is_distribution_configuration(x: Any) -> boolpublic static Boolean isDistributionConfiguration(Object x)public static bool IsDistributionConfiguration(object x)func IsDistributionConfiguration(X interface{}) *boolstatic#
Return whether the given object is a DistributionConfiguration.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.