Skip to content
v2.277.0

Experimental

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

DistributionConfigurationProps Struct ​

Properties for creating a Distribution Configuration resource.

Example ​

ts
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'
  ]
});
python
distribution_configuration = imagebuilder.DistributionConfiguration(self, "DistributionConfiguration",
    distribution_configuration_name="test-distribution-configuration",
    description="A Distribution Configuration",
    ami_distributions=[imagebuilder.AmiDistribution(
        # Distribute AMI to us-east-2 and publish the AMI ID to an SSM parameter
        region="us-east-2",
        ssm_parameters=[imagebuilder.SSMParameterConfigurations(
            parameter=ssm.StringParameter.from_string_parameter_attributes(self, "CrossRegionParameter",
                parameter_name="/imagebuilder/ami",
                force_dynamic_reference=True
            )
        )
        ]
    )
    ]
)

# For AMI-based image builds - add an AMI distribution in the current region
distribution_configuration.add_ami_distributions(
    ami_name="imagebuilder-{{ imagebuilder:buildDate }}",
    ami_description="Build AMI",
    ami_kms_key=kms.Key.from_lookup(self, "ComponentKey", alias_name="alias/distribution-encryption-key"),
    # Copy the AMI to different accounts
    ami_target_account_ids=["123456789012", "098765432109"],
    # Add launch permissions on the AMI
    ami_launch_permission=imagebuilder.AmiLaunchPermission(
        organization_arns=[
            self.format_arn(region="", service="organizations", resource="organization", resource_name="o-1234567abc")
        ],
        organizational_unit_arns=[
            self.format_arn(
                region="",
                service="organizations",
                resource="ou",
                resource_name="o-1234567abc/ou-a123-b4567890"
            )
        ],
        is_public_user_group=True,
        account_ids=["234567890123"]
    ),
    # Attach tags to the AMI
    ami_tags={
        "Environment": "production",
        "Version": "{{ imagebuilder:buildVersion }}"
    },
    # Optional - publish the distributed AMI ID to an SSM parameter
    ssm_parameters=[imagebuilder.SSMParameterConfigurations(
        parameter=ssm.StringParameter.from_string_parameter_attributes(self, "Parameter",
            parameter_name="/imagebuilder/ami",
            force_dynamic_reference=True
        )
    ), imagebuilder.SSMParameterConfigurations(
        ami_account="098765432109",
        data_type=ssm.ParameterDataType.TEXT,
        parameter=ssm.StringParameter.from_string_parameter_attributes(self, "CrossAccountParameter",
            parameter_name="imagebuilder-prod-ami",
            force_dynamic_reference=True
        )
    )
    ],
    # Optional - create a new launch template version with the distributed AMI ID
    launch_templates=[imagebuilder.LaunchTemplateConfiguration(
        launch_template=ec2.LaunchTemplate.from_launch_template_attributes(self, "LaunchTemplate",
            launch_template_id="lt-1234"
        ),
        set_default_version=True
    ), imagebuilder.LaunchTemplateConfiguration(
        account_id="123456789012",
        launch_template=ec2.LaunchTemplate.from_launch_template_attributes(self, "CrossAccountLaunchTemplate",
            launch_template_id="lt-5678"
        ),
        set_default_version=True
    )
    ],
    # Optional - enable Fast Launch on an imported launch template
    fast_launch_configurations=[imagebuilder.FastLaunchConfiguration(
        enabled=True,
        launch_template=ec2.LaunchTemplate.from_launch_template_attributes(self, "FastLaunchLT",
            launch_template_name="fast-launch-lt"
        ),
        max_parallel_launches=10,
        target_snapshot_count=2
    )
    ],
    # Optional - license configurations to apply to the AMI
    license_configuration_arns=["arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-abcdefghijklmnopqrstuvwxyz"
    ]
)
java
DistributionConfiguration distributionConfiguration = DistributionConfiguration.Builder.create(this, "DistributionConfiguration")
        .distributionConfigurationName("test-distribution-configuration")
        .description("A Distribution Configuration")
        .amiDistributions(List.of(AmiDistribution.builder()
                // Distribute AMI to us-east-2 and publish the AMI ID to an SSM parameter
                .region("us-east-2")
                .ssmParameters(List.of(SSMParameterConfigurations.builder()
                        .parameter(StringParameter.fromStringParameterAttributes(this, "CrossRegionParameter", StringParameterAttributes.builder()
                                .parameterName("/imagebuilder/ami")
                                .forceDynamicReference(true)
                                .build()))
                        .build()))
                .build()))
        .build();

// For AMI-based image builds - add an AMI distribution in the current region
distributionConfiguration.addAmiDistributions(AmiDistribution.builder()
        .amiName("imagebuilder-{{ imagebuilder:buildDate }}")
        .amiDescription("Build AMI")
        .amiKmsKey(Key.fromLookup(this, "ComponentKey", KeyLookupOptions.builder().aliasName("alias/distribution-encryption-key").build()))
        // Copy the AMI to different accounts
        .amiTargetAccountIds(List.of("123456789012", "098765432109"))
        // Add launch permissions on the AMI
        .amiLaunchPermission(AmiLaunchPermission.builder()
                .organizationArns(List.of(this.formatArn(ArnComponents.builder().region("").service("organizations").resource("organization").resourceName("o-1234567abc").build())))
                .organizationalUnitArns(List.of(this.formatArn(ArnComponents.builder()
                        .region("")
                        .service("organizations")
                        .resource("ou")
                        .resourceName("o-1234567abc/ou-a123-b4567890")
                        .build())))
                .isPublicUserGroup(true)
                .accountIds(List.of("234567890123"))
                .build())
        // Attach tags to the AMI
        .amiTags(Map.of(
                "Environment", "production",
                "Version", "{{ imagebuilder:buildVersion }}"))
        // Optional - publish the distributed AMI ID to an SSM parameter
        .ssmParameters(List.of(SSMParameterConfigurations.builder()
                .parameter(StringParameter.fromStringParameterAttributes(this, "Parameter", StringParameterAttributes.builder()
                        .parameterName("/imagebuilder/ami")
                        .forceDynamicReference(true)
                        .build()))
                .build(), SSMParameterConfigurations.builder()
                .amiAccount("098765432109")
                .dataType(ParameterDataType.TEXT)
                .parameter(StringParameter.fromStringParameterAttributes(this, "CrossAccountParameter", StringParameterAttributes.builder()
                        .parameterName("imagebuilder-prod-ami")
                        .forceDynamicReference(true)
                        .build()))
                .build()))
        // Optional - create a new launch template version with the distributed AMI ID
        .launchTemplates(List.of(LaunchTemplateConfiguration.builder()
                .launchTemplate(LaunchTemplate.fromLaunchTemplateAttributes(this, "LaunchTemplate", LaunchTemplateAttributes.builder()
                        .launchTemplateId("lt-1234")
                        .build()))
                .setDefaultVersion(true)
                .build(), LaunchTemplateConfiguration.builder()
                .accountId("123456789012")
                .launchTemplate(LaunchTemplate.fromLaunchTemplateAttributes(this, "CrossAccountLaunchTemplate", LaunchTemplateAttributes.builder()
                        .launchTemplateId("lt-5678")
                        .build()))
                .setDefaultVersion(true)
                .build()))
        // Optional - enable Fast Launch on an imported launch template
        .fastLaunchConfigurations(List.of(FastLaunchConfiguration.builder()
                .enabled(true)
                .launchTemplate(LaunchTemplate.fromLaunchTemplateAttributes(this, "FastLaunchLT", LaunchTemplateAttributes.builder()
                        .launchTemplateName("fast-launch-lt")
                        .build()))
                .maxParallelLaunches(10)
                .targetSnapshotCount(2)
                .build()))
        // Optional - license configurations to apply to the AMI
        .licenseConfigurationArns(List.of("arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-abcdefghijklmnopqrstuvwxyz"))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var distributionConfiguration = new DistributionConfiguration(this, "DistributionConfiguration", new DistributionConfigurationProps {
    DistributionConfigurationName = "test-distribution-configuration",
    Description = "A Distribution Configuration",
    AmiDistributions = new [] { new AmiDistribution {
        // Distribute AMI to us-east-2 and publish the AMI ID to an SSM parameter
        Region = "us-east-2",
        SsmParameters = new [] { new SSMParameterConfigurations {
            Parameter = StringParameter.FromStringParameterAttributes(this, "CrossRegionParameter", new StringParameterAttributes {
                ParameterName = "/imagebuilder/ami",
                ForceDynamicReference = true
            })
        } }
    } }
});

// For AMI-based image builds - add an AMI distribution in the current region
distributionConfiguration.AddAmiDistributions(new AmiDistribution {
    AmiName = "imagebuilder-{{ imagebuilder:buildDate }}",
    AmiDescription = "Build AMI",
    AmiKmsKey = Key.FromLookup(this, "ComponentKey", new KeyLookupOptions { AliasName = "alias/distribution-encryption-key" }),
    // Copy the AMI to different accounts
    AmiTargetAccountIds = new [] { "123456789012", "098765432109" },
    // Add launch permissions on the AMI
    AmiLaunchPermission = new AmiLaunchPermission {
        OrganizationArns = new [] { FormatArn(new ArnComponents { Region = "", Service = "organizations", Resource = "organization", ResourceName = "o-1234567abc" }) },
        OrganizationalUnitArns = new [] { FormatArn(new ArnComponents {
            Region = "",
            Service = "organizations",
            Resource = "ou",
            ResourceName = "o-1234567abc/ou-a123-b4567890"
        }) },
        IsPublicUserGroup = true,
        AccountIds = new [] { "234567890123" }
    },
    // Attach tags to the AMI
    AmiTags = new Dictionary<string, string> {
        { "Environment", "production" },
        { "Version", "{{ imagebuilder:buildVersion }}" }
    },
    // Optional - publish the distributed AMI ID to an SSM parameter
    SsmParameters = new [] { new SSMParameterConfigurations {
        Parameter = StringParameter.FromStringParameterAttributes(this, "Parameter", new StringParameterAttributes {
            ParameterName = "/imagebuilder/ami",
            ForceDynamicReference = true
        })
    }, new SSMParameterConfigurations {
        AmiAccount = "098765432109",
        DataType = ParameterDataType.TEXT,
        Parameter = StringParameter.FromStringParameterAttributes(this, "CrossAccountParameter", new StringParameterAttributes {
            ParameterName = "imagebuilder-prod-ami",
            ForceDynamicReference = true
        })
    } },
    // Optional - create a new launch template version with the distributed AMI ID
    LaunchTemplates = new [] { new LaunchTemplateConfiguration {
        LaunchTemplate = LaunchTemplate.FromLaunchTemplateAttributes(this, "LaunchTemplate", new LaunchTemplateAttributes {
            LaunchTemplateId = "lt-1234"
        }),
        SetDefaultVersion = true
    }, new LaunchTemplateConfiguration {
        AccountId = "123456789012",
        LaunchTemplate = LaunchTemplate.FromLaunchTemplateAttributes(this, "CrossAccountLaunchTemplate", new LaunchTemplateAttributes {
            LaunchTemplateId = "lt-5678"
        }),
        SetDefaultVersion = true
    } },
    // Optional - enable Fast Launch on an imported launch template
    FastLaunchConfigurations = new [] { new FastLaunchConfiguration {
        Enabled = true,
        LaunchTemplate = LaunchTemplate.FromLaunchTemplateAttributes(this, "FastLaunchLT", new LaunchTemplateAttributes {
            LaunchTemplateName = "fast-launch-lt"
        }),
        MaxParallelLaunches = 10,
        TargetSnapshotCount = 2
    } },
    // Optional - license configurations to apply to the AMI
    LicenseConfigurationArns = new [] { "arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-abcdefghijklmnopqrstuvwxyz" }
});
go
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
distributionConfiguration := imagebuilder.NewDistributionConfiguration(this, jsii.String("DistributionConfiguration"), &DistributionConfigurationProps{
	DistributionConfigurationName: jsii.String("test-distribution-configuration"),
	Description: jsii.String("A Distribution Configuration"),
	AmiDistributions: []AmiDistribution{
		&AmiDistribution{
			// Distribute AMI to us-east-2 and publish the AMI ID to an SSM parameter
			Region: jsii.String("us-east-2"),
			SsmParameters: []SSMParameterConfigurations{
				&SSMParameterConfigurations{
					Parameter: ssm.StringParameter_FromStringParameterAttributes(this, jsii.String("CrossRegionParameter"), &StringParameterAttributes{
						ParameterName: jsii.String("/imagebuilder/ami"),
						ForceDynamicReference: jsii.Boolean(true),
					}),
				},
			},
		},
	},
})

// For AMI-based image builds - add an AMI distribution in the current region
distributionConfiguration.AddAmiDistributions(&AmiDistribution{
	AmiName: jsii.String("imagebuilder-{{ imagebuilder:buildDate }}"),
	AmiDescription: jsii.String("Build AMI"),
	AmiKmsKey: kms.Key_FromLookup(this, jsii.String("ComponentKey"), &KeyLookupOptions{
		AliasName: jsii.String("alias/distribution-encryption-key"),
	}),
	// Copy the AMI to different accounts
	AmiTargetAccountIds: []*string{
		jsii.String("123456789012"),
		jsii.String("098765432109"),
	},
	// Add launch permissions on the AMI
	AmiLaunchPermission: &AmiLaunchPermission{
		OrganizationArns: []*string{
			this.FormatArn(&ArnComponents{
				Region: jsii.String(""),
				Service: jsii.String("organizations"),
				Resource: jsii.String("organization"),
				ResourceName: jsii.String("o-1234567abc"),
			}),
		},
		OrganizationalUnitArns: []*string{
			this.*FormatArn(&ArnComponents{
				Region: jsii.String(""),
				Service: jsii.String("organizations"),
				Resource: jsii.String("ou"),
				ResourceName: jsii.String("o-1234567abc/ou-a123-b4567890"),
			}),
		},
		IsPublicUserGroup: jsii.Boolean(true),
		AccountIds: []*string{
			jsii.String("234567890123"),
		},
	},
	// Attach tags to the AMI
	AmiTags: map[string]*string{
		"Environment": jsii.String("production"),
		"Version": jsii.String("{{ imagebuilder:buildVersion }}"),
	},
	// Optional - publish the distributed AMI ID to an SSM parameter
	SsmParameters: []SSMParameterConfigurations{
		&SSMParameterConfigurations{
			Parameter: ssm.StringParameter_*FromStringParameterAttributes(this, jsii.String("Parameter"), &StringParameterAttributes{
				ParameterName: jsii.String("/imagebuilder/ami"),
				ForceDynamicReference: jsii.Boolean(true),
			}),
		},
		&SSMParameterConfigurations{
			AmiAccount: jsii.String("098765432109"),
			DataType: ssm.ParameterDataType_TEXT,
			Parameter: ssm.StringParameter_*FromStringParameterAttributes(this, jsii.String("CrossAccountParameter"), &StringParameterAttributes{
				ParameterName: jsii.String("imagebuilder-prod-ami"),
				ForceDynamicReference: jsii.Boolean(true),
			}),
		},
	},
	// Optional - create a new launch template version with the distributed AMI ID
	LaunchTemplates: []LaunchTemplateConfiguration{
		&LaunchTemplateConfiguration{
			LaunchTemplate: ec2.LaunchTemplate_FromLaunchTemplateAttributes(this, jsii.String("LaunchTemplate"), &LaunchTemplateAttributes{
				LaunchTemplateId: jsii.String("lt-1234"),
			}),
			SetDefaultVersion: jsii.Boolean(true),
		},
		&LaunchTemplateConfiguration{
			AccountId: jsii.String("123456789012"),
			LaunchTemplate: ec2.LaunchTemplate_*FromLaunchTemplateAttributes(this, jsii.String("CrossAccountLaunchTemplate"), &LaunchTemplateAttributes{
				LaunchTemplateId: jsii.String("lt-5678"),
			}),
			SetDefaultVersion: jsii.Boolean(true),
		},
	},
	// Optional - enable Fast Launch on an imported launch template
	FastLaunchConfigurations: []FastLaunchConfiguration{
		&FastLaunchConfiguration{
			Enabled: jsii.Boolean(true),
			LaunchTemplate: ec2.LaunchTemplate_*FromLaunchTemplateAttributes(this, jsii.String("FastLaunchLT"), &LaunchTemplateAttributes{
				LaunchTemplateName: jsii.String("fast-launch-lt"),
			}),
			MaxParallelLaunches: jsii.Number(10),
			TargetSnapshotCount: jsii.Number(2),
		},
	},
	// Optional - license configurations to apply to the AMI
	LicenseConfigurationArns: []*string{
		jsii.String("arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-abcdefghijklmnopqrstuvwxyz"),
	},
})

Properties ​

amiDistributionsoptionalAmiDistribution[]ami_distributionsoptionaltyping.List[AmiDistribution]amiDistributionsoptionalList<AmiDistribution>AmiDistributionsoptionalAmiDistribution[]AmiDistributionsoptional*[]AmiDistribution #
The list of target regions and associated AMI distribution settings where the built AMI will be distributed.

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

AMI distributions may also be added with the addAmiDistributions method.

containerDistributionsoptionalContainerDistribution[]container_distributionsoptionaltyping.List[ContainerDistribution]containerDistributionsoptionalList<ContainerDistribution>ContainerDistributionsoptionalContainerDistribution[]ContainerDistributionsoptional*[]ContainerDistribution #
The list of target regions and associated container distribution settings where the built container will be distributed.

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

Container distributions may also be added with the addContainerDistributions method.

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string = None #
The description of the distribution configuration.
distributionConfigurationNameoptionalstringdistribution_configuration_nameoptionalstrdistributionConfigurationNameoptionalStringDistributionConfigurationNameoptionalstringDistributionConfigurationNameoptional*string #
The name of the distribution configuration.

Default: A name is generated

tagsoptional{ [key: string]: string }tagsoptionaltyping.Mapping[str, str]tagsoptionalMap<String, String>TagsoptionalIDictionary<string, string>Tagsoptional*map[string]*string = None #
The tags to apply to the distribution configuration.