InfrastructureConfiguration

class aws_cdk.aws_imagebuilder_alpha.InfrastructureConfiguration(scope, id, *, description=None, ec2_instance_availability_zone=None, ec2_instance_host_id=None, ec2_instance_host_resource_group_arn=None, ec2_instance_tenancy=None, http_put_response_hop_limit=None, http_tokens=None, infrastructure_configuration_name=None, instance_profile=None, instance_types=None, key_pair=None, logging=None, notification_topic=None, resource_tags=None, role=None, security_groups=None, subnet_selection=None, tags=None, terminate_instance_on_failure=None, vpc=None)

Bases: Resource

(experimental) Represents an EC2 Image Builder Infrastructure Configuration.

See:

https://docs.aws.amazon.com/imagebuilder/latest/userguide/manage-infra-config.html

Stability:

experimental

ExampleMetadata:

infused

Example:

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
)
Parameters:
  • scope (Construct)

  • id (str)

  • description (Optional[str]) – (experimental) The description of the infrastructure configuration. Default: None

  • ec2_instance_availability_zone (Optional[str]) – (experimental) The availability zone to place Image Builder build and test EC2 instances. Default: EC2 will select a random zone

  • ec2_instance_host_id (Optional[str]) – (experimental) The ID of the Dedicated Host on which build and test instances run. This only applies if the instance tenancy is host. This cannot be used with the ec2InstanceHostResourceGroupArn parameter. Default: None

  • ec2_instance_host_resource_group_arn (Optional[str]) – (experimental) The ARN of the host resource group on which build and test instances run. This only applies if the instance tenancy is host. This cannot be used with the ec2InstanceHostId parameter. Default: None

  • ec2_instance_tenancy (Optional[Tenancy]) – (experimental) The tenancy of the instance. Dedicated tenancy runs instances on single-tenant hardware, while host tenancy runs instances on a dedicated host. Shared tenancy is used by default. Default: Tenancy.DEFAULT

  • http_put_response_hop_limit (Union[int, float, None]) – (experimental) The maximum number of hops that an instance metadata request can traverse to reach its destination. By default, this is set to 2. Default: 2

  • http_tokens (Optional[HttpTokens]) – (experimental) Indicates whether a signed token header is required for instance metadata retrieval requests. By default, this is set to required to require IMDSv2 on build and test EC2 instances. Default: HttpTokens.REQUIRED

  • infrastructure_configuration_name (Optional[str]) – (experimental) The name of the infrastructure configuration. This name must be normalized by transforming all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens. Default: A name is generated

  • instance_profile (Optional[IInstanceProfile]) – (experimental) The instance profile to associate with the instance used to customize the AMI. By default, an instance profile and role will be created with minimal permissions needed to build the image, attached to the EC2 instance. If an S3 logging bucket and key prefix is provided, an IAM inline policy will be attached to the instance profile’s role, allowing s3:PutObject permissions on the bucket. Default: An instance profile will be generated

  • instance_types (Optional[Sequence[InstanceType]]) – (experimental) The instance types to launch build and test EC2 instances with. Default: Image Builder will choose from a default set of instance types compatible with the AMI

  • key_pair (Optional[IKeyPair]) – (experimental) The key pair used to connect to the build and test EC2 instances. The key pair can be used to log into the build or test instances for troubleshooting any failures. Default: None

  • logging (Union[InfrastructureConfigurationLogging, Dict[str, Any], None]) – (experimental) The log settings for detailed build logging. Default: None

  • notification_topic (Optional[ITopic]) – (experimental) The SNS topic on which notifications are sent when an image build completes. Default: No notifications are sent

  • resource_tags (Optional[Mapping[str, str]]) – (experimental) The additional tags to assign to the Amazon EC2 instance that Image Builder launches during the build process. Default: None

  • role (Optional[IRole]) – (experimental) An IAM role to associate with the instance profile used by Image Builder. The role must be assumable by the service principal ec2.amazonaws.com: Note: You can provide an instanceProfile or a role, but not both. Default: A role will automatically be created, it can be accessed via the role property

  • security_groups (Optional[Sequence[ISecurityGroup]]) – (experimental) The security groups to associate with the instance used to customize the AMI. Default: The default security group for the VPC will be used

  • subnet_selection (Union[SubnetSelection, Dict[str, Any], None]) – (experimental) Select which subnet to place the instance used to customize the AMI. The first subnet that is selected will be used. You must specify the VPC to customize the subnet selection. Default: The first subnet selected from the provided VPC will be used

  • tags (Optional[Mapping[str, str]]) – (experimental) The tags to apply to the infrastructure configuration. Default: None

  • terminate_instance_on_failure (Optional[bool]) – (experimental) Whether to terminate the EC2 instance when the build or test workflow fails. Default: true

  • vpc (Optional[IVpc]) – (experimental) The VPC to place the instance used to customize the AMI. Default: The default VPC will be used

Stability:

experimental

Methods

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 infrastructure configuration.

Parameters:
  • grantee (IGrantable) –

    • The principal.

  • actions (str) –

    • The list of actions.

Stability:

experimental

Return type:

Grant

grant_read(grantee)

(experimental) Grant read permissions to the given grantee for the infrastructure configuration.

Parameters:

grantee (IGrantable) –

  • The principal.

Stability:

experimental

Return type:

Grant

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

PROPERTY_INJECTION_ID = '@aws-cdk.aws-imagebuilder-alpha.InfrastructureConfiguration'
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.

infrastructure_configuration_arn

(experimental) The ARN of the infrastructure configuration.

Stability:

experimental

infrastructure_configuration_name

(experimental) The name of the infrastructure configuration.

Stability:

experimental

instance_profile

(experimental) The EC2 instance profile to use for the build.

Stability:

experimental

log_bucket

(experimental) The bucket used to upload image build logs.

Stability:

experimental

node

The tree node.

role

(experimental) The role associated with the EC2 instance profile used for the build.

Stability:

experimental

stack

The stack in which this resource is defined.

Static Methods

classmethod from_infrastructure_configuration_arn(scope, id, infrastructure_configuration_arn)

(experimental) Import an existing infrastructure configuration given its ARN.

Parameters:
  • scope (Construct)

  • id (str)

  • infrastructure_configuration_arn (str)

Stability:

experimental

Return type:

IInfrastructureConfiguration

classmethod from_infrastructure_configuration_name(scope, id, infrastructure_configuration_name)

(experimental) Import an existing infrastructure 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)

  • infrastructure_configuration_name (str)

Stability:

experimental

Return type:

IInfrastructureConfiguration

classmethod is_construct(x)

Checks if x is a construct.

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:

x (Any) – Any object.

Return type:

bool

Returns:

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

classmethod is_infrastructure_configuration(x)

(experimental) Return whether the given object is an InfrastructureConfiguration.

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