Show / Hide Table of Contents

Interface ILaunchTemplateProps

Properties of a LaunchTemplate.

Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface ILaunchTemplateProps
Syntax (vb)
Public Interface ILaunchTemplateProps
Remarks

ExampleMetadata: infused

Examples
Vpc vpc;


            var sg1 = new SecurityGroup(this, "sg1", new SecurityGroupProps {
                Vpc = vpc
            });
            var sg2 = new SecurityGroup(this, "sg2", new SecurityGroupProps {
                Vpc = vpc
            });

            var launchTemplate = new LaunchTemplate(this, "LaunchTemplate", new LaunchTemplateProps {
                MachineImage = MachineImage.LatestAmazonLinux2023(),
                SecurityGroup = sg1
            });

            launchTemplate.AddSecurityGroup(sg2);

Synopsis

Properties

AssociatePublicIpAddress

Whether instances should have a public IP addresses associated with them.

BlockDevices

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

CpuCredits

CPU credit type for burstable EC2 instance types.

DetailedMonitoring

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

DisableApiTermination

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;

EbsOptimized

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

HibernationConfigured

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

HttpEndpoint

Enables or disables the HTTP metadata endpoint on your instances.

HttpProtocolIpv6

Enables or disables the IPv6 endpoint for the instance metadata service.

HttpPutResponseHopLimit

The desired HTTP PUT response hop limit for instance metadata requests.

HttpTokens

The state of token usage for your instance metadata requests.

InstanceInitiatedShutdownBehavior

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

InstanceMetadataTags

Set to enabled to allow access to instance tags from the instance metadata.

InstanceProfile

The instance profile used to pass role information to EC2 instances.

InstanceType

Type of instance to launch.

KeyName

(deprecated) Name of SSH keypair to grant access to instance.

KeyPair

The SSH keypair to grant access to the instance.

LaunchTemplateName

Name for this launch template.

MachineImage

The AMI that will be used by instances.

NitroEnclaveEnabled

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

PlacementGroup

The placement group that you want to launch the instance into.

RequireImdsv2

Whether IMDSv2 should be required on launched instances.

Role

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

SecurityGroup

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

SpotOptions

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.

UserData

The user data to make available to the instance.

VersionDescription

A description for the first version of the launch template.

Properties

AssociatePublicIpAddress

Whether instances should have a public IP addresses associated with them.

bool? AssociatePublicIpAddress { get; }
Property Value

bool?

Remarks

Default: - Use subnet settings

BlockDevices

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

IBlockDevice[]? BlockDevices { get; }
Property Value

IBlockDevice[]

Remarks

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

CpuCredits

CPU credit type for burstable EC2 instance types.

CpuCredits? CpuCredits { get; }
Property Value

CpuCredits?

Remarks

Default: - No credit type is specified in the Launch Template.

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

DetailedMonitoring

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

bool? DetailedMonitoring { get; }
Property Value

bool?

Remarks

Default: False - Detailed monitoring is disabled.

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

DisableApiTermination

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;

bool? DisableApiTermination { get; }
Property Value

bool?

Remarks

otherwise, you can.

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

EbsOptimized

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

bool? EbsOptimized { get; }
Property Value

bool?

Remarks

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.

HibernationConfigured

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

bool? HibernationConfigured { get; }
Property Value

bool?

Remarks

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

HttpEndpoint

Enables or disables the HTTP metadata endpoint on your instances.

bool? HttpEndpoint { get; }
Property Value

bool?

Remarks

Default: true

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata-metadataoptions.html#cfn-ec2-launchtemplate-launchtemplatedata-metadataoptions-httpendpoint

HttpProtocolIpv6

Enables or disables the IPv6 endpoint for the instance metadata service.

bool? HttpProtocolIpv6 { get; }
Property Value

bool?

Remarks

Default: true

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata-metadataoptions.html#cfn-ec2-launchtemplate-launchtemplatedata-metadataoptions-httpprotocolipv6

HttpPutResponseHopLimit

The desired HTTP PUT response hop limit for instance metadata requests.

double? HttpPutResponseHopLimit { get; }
Property Value

double?

Remarks

The larger the number, the further instance metadata requests can travel.

Default: 1

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata-metadataoptions.html#cfn-ec2-launchtemplate-launchtemplatedata-metadataoptions-httpputresponsehoplimit

HttpTokens

The state of token usage for your instance metadata requests.

LaunchTemplateHttpTokens? HttpTokens { get; }
Property Value

LaunchTemplateHttpTokens?

Remarks

The default state is optional if not specified. However, if requireImdsv2 is true, the state must be required.

Default: LaunchTemplateHttpTokens.OPTIONAL

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata-metadataoptions.html#cfn-ec2-launchtemplate-launchtemplatedata-metadataoptions-httptokens

InstanceInitiatedShutdownBehavior

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

InstanceInitiatedShutdownBehavior? InstanceInitiatedShutdownBehavior { get; }
Property Value

InstanceInitiatedShutdownBehavior?

Remarks

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

InstanceMetadataTags

Set to enabled to allow access to instance tags from the instance metadata.

bool? InstanceMetadataTags { get; }
Property Value

bool?

Remarks

Set to disabled to turn off access to instance tags from the instance metadata.

Default: false

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata-metadataoptions.html#cfn-ec2-launchtemplate-launchtemplatedata-metadataoptions-instancemetadatatags

InstanceProfile

The instance profile used to pass role information to EC2 instances.

IInstanceProfile? InstanceProfile { get; }
Property Value

IInstanceProfile

Remarks

Note: You can provide an instanceProfile or a role, but not both.

Default: - No instance profile

InstanceType

Type of instance to launch.

InstanceType? InstanceType { get; }
Property Value

InstanceType

Remarks

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

KeyName

(deprecated) Name of SSH keypair to grant access to instance.

[Obsolete("- Use `keyPair` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair")]
string? KeyName { get; }
Property Value

string

Remarks

Default: - No SSH access will be possible.

Stability: Deprecated

KeyPair

The SSH keypair to grant access to the instance.

IKeyPair? KeyPair { get; }
Property Value

IKeyPair

Remarks

Default: - No SSH access will be possible.

LaunchTemplateName

Name for this launch template.

string? LaunchTemplateName { get; }
Property Value

string

Remarks

Default: Automatically generated name

MachineImage

The AMI that will be used by instances.

IMachineImage? MachineImage { get; }
Property Value

IMachineImage

Remarks

Default: - This Launch Template does not specify a default AMI.

NitroEnclaveEnabled

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

bool? NitroEnclaveEnabled { get; }
Property Value

bool?

Remarks

otherwise, it is not enabled for AWS Nitro Enclaves.

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

PlacementGroup

The placement group that you want to launch the instance into.

IPlacementGroupRef? PlacementGroup { get; }
Property Value

IPlacementGroupRef

Remarks

Default: - no placement group will be used for this launch template.

RequireImdsv2

Whether IMDSv2 should be required on launched instances.

bool? RequireImdsv2 { get; }
Property Value

bool?

Remarks

Default: - false

Role

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

IRole? Role { get; }
Property Value

IRole

Remarks

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: - No new role is created.

Examples
var role = new Role(this, "MyRole", new RoleProps {
                 AssumedBy = new ServicePrincipal("ec2.amazonaws.com")
             });

SecurityGroup

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

ISecurityGroup? SecurityGroup { get; }
Property Value

ISecurityGroup

Remarks

Default: No security group is assigned.

SpotOptions

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.

ILaunchTemplateSpotOptions? SpotOptions { get; }
Property Value

ILaunchTemplateSpotOptions

Remarks

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

UserData

The user data to make available to the instance.

UserData? UserData { get; }
Property Value

UserData

Remarks

Default: - This Launch Template creates a UserData based on the type of provided machineImage; no UserData is created if a machineImage is not provided

VersionDescription

A description for the first version of the launch template.

string? VersionDescription { get; }
Property Value

string

Remarks

The version description must be maximum 255 characters long.

Default: - No description

See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-launchtemplate.html#cfn-ec2-launchtemplate-versiondescription

Back to top Generated by DocFX