InfrastructureConfigurationProps

class aws_cdk.aws_imagebuilder_alpha.InfrastructureConfigurationProps(*, 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: object

(experimental) Properties for creating an Infrastructure Configuration resource.

Parameters:
  • 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

ExampleMetadata:

infused

Example:

infrastructure_configuration = imagebuilder.InfrastructureConfiguration(self, "InfrastructureConfiguration",
    infrastructure_configuration_name="test-infrastructure-configuration",
    description="An Infrastructure Configuration",
    # Optional - instance types to use for build/test
    instance_types=[
        ec2.InstanceType.of(ec2.InstanceClass.STANDARD7_INTEL, ec2.InstanceSize.LARGE),
        ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.LARGE)
    ],
    # Optional - create an instance profile with necessary permissions
    instance_profile=iam.InstanceProfile(self, "InstanceProfile",
        instance_profile_name="test-instance-profile",
        role=iam.Role(self, "InstanceProfileRole",
            assumed_by=iam.ServicePrincipal.from_static_service_principle_name("ec2.amazonaws.com"),
            managed_policies=[
                iam.ManagedPolicy.from_aws_managed_policy_name("AmazonSSMManagedInstanceCore"),
                iam.ManagedPolicy.from_aws_managed_policy_name("EC2InstanceProfileForImageBuilder")
            ]
        )
    ),
    # Use VPC network configuration
    vpc=vpc,
    subnet_selection=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PUBLIC),
    security_groups=[ec2.SecurityGroup.from_security_group_id(self, "SecurityGroup", vpc.vpc_default_security_group)],
    key_pair=ec2.KeyPair.from_key_pair_name(self, "KeyPair", "imagebuilder-instance-key-pair"),
    terminate_instance_on_failure=True,
    # Optional - IMDSv2 settings
    http_tokens=imagebuilder.HttpTokens.REQUIRED,
    http_put_response_hop_limit=1,
    # Optional - publish image completion messages to an SNS topic
    notification_topic=sns.Topic.from_topic_arn(self, "Topic",
        self.format_arn(service="sns", resource="image-builder-topic")),
    # Optional - log settings. Logging is enabled by default
    logging=imagebuilder.InfrastructureConfigurationLogging(
        s3_bucket=s3.Bucket.from_bucket_name(self, "LogBucket", f"imagebuilder-logging-{Aws.ACCOUNT_ID}"),
        s3_key_prefix="imagebuilder-logs"
    ),
    # Optional - host placement settings
    ec2_instance_availability_zone=Stack.of(self).availability_zones[0],
    ec2_instance_host_id=dedicated_host.attr_host_id,
    ec2_instance_tenancy=imagebuilder.Tenancy.HOST,
    resource_tags={
        "Environment": "production"
    }
)

Attributes

description

(experimental) The description of the infrastructure configuration.

Default:

None

Stability:

experimental

ec2_instance_availability_zone

(experimental) The availability zone to place Image Builder build and test EC2 instances.

Default:

EC2 will select a random zone

Stability:

experimental

ec2_instance_host_id

(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

Stability:

experimental

ec2_instance_host_resource_group_arn

(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

Stability:

experimental

ec2_instance_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

Stability:

experimental

http_put_response_hop_limit

(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

Stability:

experimental

http_tokens

(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

Stability:

experimental

infrastructure_configuration_name

(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

Stability:

experimental

instance_profile

(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

Stability:

experimental

instance_types

(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

Stability:

experimental

key_pair

(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

Stability:

experimental

logging

(experimental) The log settings for detailed build logging.

Default:

None

Stability:

experimental

notification_topic

(experimental) The SNS topic on which notifications are sent when an image build completes.

Default:

No notifications are sent

Stability:

experimental

resource_tags

(experimental) The additional tags to assign to the Amazon EC2 instance that Image Builder launches during the build process.

Default:

None

Stability:

experimental

role

(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

Stability:

experimental

Example:

role = iam.Role(self, "MyRole",
    assumed_by=iam.ServicePrincipal("ec2.amazonaws.com")
)
security_groups

(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

Stability:

experimental

subnet_selection

(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

Stability:

experimental

tags

(experimental) The tags to apply to the infrastructure configuration.

Default:

None

Stability:

experimental

terminate_instance_on_failure

(experimental) Whether to terminate the EC2 instance when the build or test workflow fails.

Default:

true

Stability:

experimental

vpc

(experimental) The VPC to place the instance used to customize the AMI.

Default:

The default VPC will be used

Stability:

experimental