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; |
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 AMI that will be used by instances. |
VersionDescription | A description for the first version of the launch template. |
Properties
AssociatePublicIpAddress
Whether instances should have a public IP addresses associated with them.
virtual Nullable<bool> AssociatePublicIpAddress { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: - Use subnet settings
BlockDevices
Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes.
virtual IBlockDevice[] BlockDevices { get; }
Property Value
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.
virtual Nullable<CpuCredits> CpuCredits { get; }
Property Value
System.Nullable<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.
virtual Nullable<bool> DetailedMonitoring { get; }
Property Value
System.Nullable<System.Boolean>
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;
virtual Nullable<bool> DisableApiTermination { get; }
Property Value
System.Nullable<System.Boolean>
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.
virtual Nullable<bool> EbsOptimized { get; }
Property Value
System.Nullable<System.Boolean>
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.
virtual Nullable<bool> HibernationConfigured { get; }
Property Value
System.Nullable<System.Boolean>
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.
virtual Nullable<bool> HttpEndpoint { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
HttpProtocolIpv6
Enables or disables the IPv6 endpoint for the instance metadata service.
virtual Nullable<bool> HttpProtocolIpv6 { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
HttpPutResponseHopLimit
The desired HTTP PUT response hop limit for instance metadata requests.
virtual Nullable<double> HttpPutResponseHopLimit { get; }
Property Value
System.Nullable<System.Double>
Remarks
The larger the number, the further instance metadata requests can travel.
Default: 1
HttpTokens
The state of token usage for your instance metadata requests.
virtual Nullable<LaunchTemplateHttpTokens> HttpTokens { get; }
Property Value
System.Nullable<LaunchTemplateHttpTokens>
Remarks
The default state is optional
if not specified. However,
if requireImdsv2 is true, the state must be required
.
Default: LaunchTemplateHttpTokens.OPTIONAL
InstanceInitiatedShutdownBehavior
Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).
virtual Nullable<InstanceInitiatedShutdownBehavior> InstanceInitiatedShutdownBehavior { get; }
Property Value
System.Nullable<InstanceInitiatedShutdownBehavior>
Remarks
Default: - Shutdown behavior is not specified in the launch template; defaults to STOP.
InstanceMetadataTags
Set to enabled to allow access to instance tags from the instance metadata.
virtual Nullable<bool> InstanceMetadataTags { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Set to disabled to turn off access to instance tags from the instance metadata.
Default: false
InstanceProfile
The instance profile used to pass role information to EC2 instances.
virtual IInstanceProfile InstanceProfile { get; }
Property Value
Remarks
Note: You can provide an instanceProfile or a role, but not both.
Default: - No instance profile
InstanceType
Type of instance to launch.
virtual InstanceType InstanceType { get; }
Property Value
Remarks
Default: - This Launch Template does not specify a default Instance Type.
KeyName
(deprecated) Name of SSH keypair to grant access to instance.
virtual string KeyName { get; }
Property Value
System.String
Remarks
Default: - No SSH access will be possible.
Stability: Deprecated
KeyPair
The SSH keypair to grant access to the instance.
virtual IKeyPair KeyPair { get; }
Property Value
Remarks
Default: - No SSH access will be possible.
LaunchTemplateName
Name for this launch template.
virtual string LaunchTemplateName { get; }
Property Value
System.String
Remarks
Default: Automatically generated name
MachineImage
The AMI that will be used by instances.
virtual IMachineImage MachineImage { get; }
Property Value
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;
virtual Nullable<bool> NitroEnclaveEnabled { get; }
Property Value
System.Nullable<System.Boolean>
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.
RequireImdsv2
Whether IMDSv2 should be required on launched instances.
virtual Nullable<bool> RequireImdsv2 { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: - false
Role
An IAM role to associate with the instance profile that is used by instances.
virtual IRole Role { get; }
Property Value
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.
virtual ISecurityGroup SecurityGroup { get; }
Property Value
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.
virtual ILaunchTemplateSpotOptions SpotOptions { get; }
Property Value
Remarks
Default: - Instance launched with this template will not be spot instances.
UserData
The AMI that will be used by instances.
virtual UserData UserData { get; }
Property Value
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.
virtual string VersionDescription { get; }
Property Value
System.String
Remarks
The version description must be maximum 255 characters long.
Default: - No description