LaunchTemplateProps

class aws_cdk.aws_ec2.LaunchTemplateProps(*, block_devices=None, cpu_credits=None, detailed_monitoring=None, disable_api_termination=None, ebs_optimized=None, hibernation_configured=None, instance_initiated_shutdown_behavior=None, instance_type=None, key_name=None, launch_template_name=None, machine_image=None, nitro_enclave_enabled=None, role=None, security_group=None, spot_options=None, user_data=None)

Bases: object

Properties of a LaunchTemplate.

Parameters
  • block_devices (Optional[Sequence[BlockDevice]]) – Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes. Each instance that is launched has an associated root device volume, either an Amazon EBS volume or an instance store volume. You can use block device mappings to specify additional EBS volumes or instance store volumes to attach to an instance when it is launched. Default: - Uses the block device mapping of the AMI

  • cpu_credits (Optional[CpuCredits]) – CPU credit type for burstable EC2 instance types. Default: - No credit type is specified in the Launch Template.

  • detailed_monitoring (Optional[bool]) – If set to true, then detailed monitoring will be enabled on instances created with this launch template. Default: False - Detailed monitoring is disabled.

  • disable_api_termination (Optional[bool]) – If you set this parameter to true, you cannot terminate the instances launched with this launch template using the Amazon EC2 console, CLI, or API; otherwise, you can. Default: - The API termination setting is not specified in the Launch Template.

  • ebs_optimized (Optional[bool]) – Indicates whether the instances are optimized for Amazon EBS I/O. This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal Amazon EBS I/O performance. This optimization isn’t available with all instance types. Additional usage charges apply when using an EBS-optimized instance. Default: - EBS optimization is not specified in the launch template.

  • hibernation_configured (Optional[bool]) – If you set this parameter to true, the instance is enabled for hibernation. Default: - Hibernation configuration is not specified in the launch template; defaulting to false.

  • instance_initiated_shutdown_behavior (Optional[InstanceInitiatedShutdownBehavior]) – Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown). Default: - Shutdown behavior is not specified in the launch template; defaults to STOP.

  • instance_type (Optional[InstanceType]) – Type of instance to launch. Default: - This Launch Template does not specify a default Instance Type.

  • key_name (Optional[str]) – Name of SSH keypair to grant access to instance. Default: - No SSH access will be possible.

  • launch_template_name (Optional[str]) – Name for this launch template. Default: Automatically generated name

  • machine_image (Optional[IMachineImage]) – The AMI that will be used by instances. Default: - This Launch Template does not specify a default AMI.

  • nitro_enclave_enabled (Optional[bool]) – If this parameter is set to true, the instance is enabled for AWS Nitro Enclaves; otherwise, it is not enabled for AWS Nitro Enclaves. Default: - Enablement of Nitro enclaves is not specified in the launch template; defaulting to false.

  • role (Optional[IRole]) – An IAM role to associate with the instance profile that is used by instances. The role must be assumable by the service principal ec2.amazonaws.com: Default: - No new role is created.

  • security_group (Optional[ISecurityGroup]) – Security group to assign to instances created with the launch template. Default: No security group is assigned.

  • spot_options (Optional[LaunchTemplateSpotOptions]) – If this property is defined, then the Launch Template’s InstanceMarketOptions will be set to use Spot instances, and the options for the Spot instances will be as defined. Default: - Instance launched with this template will not be spot instances.

  • user_data (Optional[UserData]) – The AMI that will be used by instances. Default: - This Launch Template creates a UserData based on the type of provided machineImage; no UserData is created if a machineImage is not provided

Attributes

block_devices

Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes.

Each instance that is launched has an associated root device volume, either an Amazon EBS volume or an instance store volume. You can use block device mappings to specify additional EBS volumes or instance store volumes to attach to an instance when it is launched.

Default
  • Uses the block device mapping of the AMI

See

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html

Return type

Optional[List[BlockDevice]]

cpu_credits

CPU credit type for burstable EC2 instance types.

Default
  • No credit type is specified in the Launch Template.

See

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances.html

Return type

Optional[CpuCredits]

detailed_monitoring

If set to true, then detailed monitoring will be enabled on instances created with this launch template.

Default

False - Detailed monitoring is disabled.

See

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-cloudwatch-new.html

Return type

Optional[bool]

disable_api_termination

If you set this parameter to true, you cannot terminate the instances launched with this launch template using the Amazon EC2 console, CLI, or API;

otherwise, you can.

Default
  • The API termination setting is not specified in the Launch Template.

Return type

Optional[bool]

ebs_optimized

Indicates whether the instances are optimized for Amazon EBS I/O.

This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal Amazon EBS I/O performance. This optimization isn’t available with all instance types. Additional usage charges apply when using an EBS-optimized instance.

Default
  • EBS optimization is not specified in the launch template.

Return type

Optional[bool]

hibernation_configured

If you set this parameter to true, the instance is enabled for hibernation.

Default
  • Hibernation configuration is not specified in the launch template; defaulting to false.

Return type

Optional[bool]

instance_initiated_shutdown_behavior

Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).

Default
  • Shutdown behavior is not specified in the launch template; defaults to STOP.

See

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html#Using_ChangingInstanceInitiatedShutdownBehavior

Return type

Optional[InstanceInitiatedShutdownBehavior]

instance_type

Type of instance to launch.

Default
  • This Launch Template does not specify a default Instance Type.

Return type

Optional[InstanceType]

key_name

Name of SSH keypair to grant access to instance.

Default
  • No SSH access will be possible.

Return type

Optional[str]

launch_template_name

Name for this launch template.

Default

Automatically generated name

Return type

Optional[str]

machine_image

The AMI that will be used by instances.

Default
  • This Launch Template does not specify a default AMI.

Return type

Optional[IMachineImage]

nitro_enclave_enabled

If this parameter is set to true, the instance is enabled for AWS Nitro Enclaves;

otherwise, it is not enabled for AWS Nitro Enclaves.

Default
  • Enablement of Nitro enclaves is not specified in the launch template; defaulting to false.

Return type

Optional[bool]

role

An IAM role to associate with the instance profile that is used by instances.

The role must be assumable by the service principal ec2.amazonaws.com:

Default
  • No new role is created.

Example:

# Example automatically generated. See https://github.com/aws/jsii/issues/826
role = iam.Role(self, "MyRole",
    assumed_by=iam.ServicePrincipal("ec2.amazonaws.com")
)
Return type

Optional[IRole]

security_group

Security group to assign to instances created with the launch template.

Default

No security group is assigned.

Return type

Optional[ISecurityGroup]

spot_options

If this property is defined, then the Launch Template’s InstanceMarketOptions will be set to use Spot instances, and the options for the Spot instances will be as defined.

Default
  • Instance launched with this template will not be spot instances.

Return type

Optional[LaunchTemplateSpotOptions]

user_data

The AMI that will be used by instances.

Default

  • This Launch Template creates a UserData based on the type of provided

machineImage; no UserData is created if a machineImage is not provided

Return type

Optional[UserData]