DistributionConfiguration
- class aws_cdk.aws_imagebuilder_alpha.DistributionConfiguration(scope, id, *, ami_distributions=None, container_distributions=None, description=None, distribution_configuration_name=None, tags=None)
Bases:
Resource(experimental) Represents an EC2 Image Builder Distribution Configuration.
- See:
- Stability:
experimental
- ExampleMetadata:
infused
Example:
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" ] )
- Parameters:
scope (
Construct)id (
str)ami_distributions (
Optional[Sequence[Union[AmiDistribution,Dict[str,Any]]]]) – (experimental) The list of target regions and associated AMI distribution settings where the built AMI will be distributed. AMI distributions may also be added with theaddAmiDistributionsmethod. Default: None if container distributions are provided. Otherwise, at least one AMI or container distribution must be providedcontainer_distributions (
Optional[Sequence[Union[ContainerDistribution,Dict[str,Any]]]]) – (experimental) The list of target regions and associated container distribution settings where the built container will be distributed. Container distributions may also be added with theaddContainerDistributionsmethod. Default: None if AMI distributions are provided. Otherwise, at least one AMI or container distribution must be provideddescription (
Optional[str]) – (experimental) The description of the distribution configuration. Default: Nonedistribution_configuration_name (
Optional[str]) – (experimental) The name of the distribution configuration. Default: A name is generatedtags (
Optional[Mapping[str,str]]) – (experimental) The tags to apply to the distribution configuration. Default: None
- Stability:
experimental
Methods
- add_ami_distributions(*ami_distributions)
(experimental) Adds AMI distribution settings to the distribution configuration.
- Parameters:
ami_distributions (
AmiDistribution) – The list of AMI distribution settings to apply.- Stability:
experimental
- Return type:
None
- add_container_distributions(*container_distributions)
(experimental) Adds container distribution settings to the distribution configuration.
- Parameters:
container_distributions (
ContainerDistribution) – The list of container distribution settings to apply.- Stability:
experimental
- Return type:
None
- apply_removal_policy(policy)
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).- Parameters:
policy (
RemovalPolicy)- Return type:
None
- grant(grantee, *actions)
(experimental) Grant custom actions to the given grantee for the distribution configuration.
- Parameters:
grantee (
IGrantable) – The principal.actions (
str) – The list of actions.
- Stability:
experimental
- Return type:
- grant_read(grantee)
(experimental) Grant read permissions to the given grantee for the distribution configuration.
- Parameters:
grantee (
IGrantable) – The principal.- Stability:
experimental
- Return type:
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- PROPERTY_INJECTION_ID = '@aws-cdk.aws-imagebuilder-alpha.DistributionConfiguration'
- distribution_configuration_arn
(experimental) The ARN of the distribution configuration.
- Stability:
experimental
- distribution_configuration_name
(experimental) The name of the distribution configuration.
- Stability:
experimental
- env
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
The tree node.
- stack
The stack in which this resource is defined.
Static Methods
- classmethod from_distribution_configuration_arn(scope, id, distribution_configuration_arn)
(experimental) Import an existing distribution configuration given its ARN.
- Parameters:
scope (
Construct)id (
str)distribution_configuration_arn (
str)
- Stability:
experimental
- Return type:
- classmethod from_distribution_configuration_name(scope, id, distribution_configuration_name)
(experimental) 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.
- Parameters:
scope (
Construct)id (
str)distribution_configuration_name (
str)
- Stability:
experimental
- Return type:
- classmethod is_construct(x)
Checks if
xis a construct.Use this method instead of
instanceofto properly detectConstructinstances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructslibrary on disk are seen as independent, completely different libraries. As a consequence, the classConstructin each copy of theconstructslibrary is seen as a different class, and an instance of one class will not test asinstanceofthe other class.npm installwill not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructslibrary can be accidentally installed, andinstanceofwill behave unpredictably. It is safest to avoid usinginstanceof, and using this type-testing method instead.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsConstruct.
- classmethod is_distribution_configuration(x)
(experimental) Return whether the given object is a DistributionConfiguration.
- Parameters:
x (
Any)- Stability:
experimental
- Return type:
bool
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct)- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct)- Return type:
bool