Class LaunchTemplate.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<LaunchTemplate>
- Enclosing class:
LaunchTemplate
LaunchTemplate
.-
Method Summary
Modifier and TypeMethodDescriptionassociatePublicIpAddress
(Boolean associatePublicIpAddress) Whether instances should have a public IP addresses associated with them.blockDevices
(List<? extends BlockDevice> blockDevices) Specifies how block devices are exposed to the instance.build()
cpuCredits
(CpuCredits cpuCredits) CPU credit type for burstable EC2 instance types.static LaunchTemplate.Builder
detailedMonitoring
(Boolean detailedMonitoring) If set to true, then detailed monitoring will be enabled on instances created with this launch template.disableApiTermination
(Boolean 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
(Boolean ebsOptimized) Indicates whether the instances are optimized for Amazon EBS I/O.hibernationConfigured
(Boolean hibernationConfigured) If you set this parameter to true, the instance is enabled for hibernation.httpEndpoint
(Boolean httpEndpoint) Enables or disables the HTTP metadata endpoint on your instances.httpProtocolIpv6
(Boolean httpProtocolIpv6) Enables or disables the IPv6 endpoint for the instance metadata service.httpPutResponseHopLimit
(Number httpPutResponseHopLimit) The desired HTTP PUT response hop limit for instance metadata requests.httpTokens
(LaunchTemplateHttpTokens httpTokens) The state of token usage for your instance metadata requests.instanceInitiatedShutdownBehavior
(InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior) Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).instanceMetadataTags
(Boolean instanceMetadataTags) Set to enabled to allow access to instance tags from the instance metadata.instanceProfile
(IInstanceProfile instanceProfile) The instance profile used to pass role information to EC2 instances.instanceType
(InstanceType instanceType) Type of instance to launch.Deprecated.The SSH keypair to grant access to the instance.launchTemplateName
(String launchTemplateName) Name for this launch template.machineImage
(IMachineImage machineImage) The AMI that will be used by instances.nitroEnclaveEnabled
(Boolean nitroEnclaveEnabled) If this parameter is set to true, the instance is enabled for AWS Nitro Enclaves;requireImdsv2
(Boolean requireImdsv2) Whether IMDSv2 should be required on launched instances.An IAM role to associate with the instance profile that is used by instances.securityGroup
(ISecurityGroup securityGroup) Security group to assign to instances created with the launch template.spotOptions
(LaunchTemplateSpotOptions 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.The AMI that will be used by instances.versionDescription
(String versionDescription) A description for the first version of the launch template.
-
Method Details
-
create
@Stability(Stable) public static LaunchTemplate.Builder create(software.constructs.Construct scope, String id) - Parameters:
scope
- This parameter is required.id
- This parameter is required.- Returns:
- a new instance of
LaunchTemplate.Builder
.
-
associatePublicIpAddress
@Stability(Stable) public LaunchTemplate.Builder associatePublicIpAddress(Boolean associatePublicIpAddress) Whether instances should have a public IP addresses associated with them.Default: - Use subnet settings
- Parameters:
associatePublicIpAddress
- Whether instances should have a public IP addresses associated with them. This parameter is required.- Returns:
this
-
blockDevices
@Stability(Stable) public LaunchTemplate.Builder blockDevices(List<? extends BlockDevice> blockDevices) 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
- Parameters:
blockDevices
- Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes. This parameter is required.- Returns:
this
- See Also:
-
cpuCredits
CPU credit type for burstable EC2 instance types.Default: - No credit type is specified in the Launch Template.
- Parameters:
cpuCredits
- CPU credit type for burstable EC2 instance types. This parameter is required.- Returns:
this
- See Also:
-
detailedMonitoring
If set to true, then detailed monitoring will be enabled on instances created with this launch template.Default: False - Detailed monitoring is disabled.
- Parameters:
detailedMonitoring
- If set to true, then detailed monitoring will be enabled on instances created with this launch template. This parameter is required.- Returns:
this
- See Also:
-
disableApiTermination
@Stability(Stable) public LaunchTemplate.Builder disableApiTermination(Boolean 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;otherwise, you can.
Default: - The API termination setting is not specified in the Launch Template.
- Parameters:
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;. This parameter is required.- Returns:
this
-
ebsOptimized
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.
- Parameters:
ebsOptimized
- Indicates whether the instances are optimized for Amazon EBS I/O. This parameter is required.- Returns:
this
-
hibernationConfigured
@Stability(Stable) public LaunchTemplate.Builder hibernationConfigured(Boolean hibernationConfigured) 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.
- Parameters:
hibernationConfigured
- If you set this parameter to true, the instance is enabled for hibernation. This parameter is required.- Returns:
this
-
httpEndpoint
Enables or disables the HTTP metadata endpoint on your instances.Default: true
- Parameters:
httpEndpoint
- Enables or disables the HTTP metadata endpoint on your instances. This parameter is required.- Returns:
this
- See Also:
-
httpProtocolIpv6
Enables or disables the IPv6 endpoint for the instance metadata service.Default: true
- Parameters:
httpProtocolIpv6
- Enables or disables the IPv6 endpoint for the instance metadata service. This parameter is required.- Returns:
this
- See Also:
-
httpPutResponseHopLimit
@Stability(Stable) public LaunchTemplate.Builder httpPutResponseHopLimit(Number httpPutResponseHopLimit) The desired HTTP PUT response hop limit for instance metadata requests.The larger the number, the further instance metadata requests can travel.
Default: 1
- Parameters:
httpPutResponseHopLimit
- The desired HTTP PUT response hop limit for instance metadata requests. This parameter is required.- Returns:
this
- See Also:
-
httpTokens
The state of token usage for your instance metadata requests.The default state is
optional
if not specified. However, if requireImdsv2 is true, the state must berequired
.Default: LaunchTemplateHttpTokens.OPTIONAL
- Parameters:
httpTokens
- The state of token usage for your instance metadata requests. This parameter is required.- Returns:
this
- See Also:
-
instanceInitiatedShutdownBehavior
@Stability(Stable) public LaunchTemplate.Builder instanceInitiatedShutdownBehavior(InstanceInitiatedShutdownBehavior 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.
- Parameters:
instanceInitiatedShutdownBehavior
- Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown). This parameter is required.- Returns:
this
- See Also:
-
instanceMetadataTags
Set to enabled to allow access to instance tags from the instance metadata.Set to disabled to turn off access to instance tags from the instance metadata.
Default: false
- Parameters:
instanceMetadataTags
- Set to enabled to allow access to instance tags from the instance metadata. This parameter is required.- Returns:
this
- See Also:
-
instanceProfile
The instance profile used to pass role information to EC2 instances.Note: You can provide an instanceProfile or a role, but not both.
Default: - No instance profile
- Parameters:
instanceProfile
- The instance profile used to pass role information to EC2 instances. This parameter is required.- Returns:
this
-
instanceType
Type of instance to launch.Default: - This Launch Template does not specify a default Instance Type.
- Parameters:
instanceType
- Type of instance to launch. This parameter is required.- Returns:
this
-
keyName
Deprecated.- 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
(deprecated) Name of SSH keypair to grant access to instance.Default: - No SSH access will be possible.
- Parameters:
keyName
- Name of SSH keypair to grant access to instance. This parameter is required.- Returns:
this
- Use
-
keyPair
The SSH keypair to grant access to the instance.Default: - No SSH access will be possible.
- Parameters:
keyPair
- The SSH keypair to grant access to the instance. This parameter is required.- Returns:
this
-
launchTemplateName
Name for this launch template.Default: Automatically generated name
- Parameters:
launchTemplateName
- Name for this launch template. This parameter is required.- Returns:
this
-
machineImage
The AMI that will be used by instances.Default: - This Launch Template does not specify a default AMI.
- Parameters:
machineImage
- The AMI that will be used by instances. This parameter is required.- Returns:
this
-
nitroEnclaveEnabled
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.
- Parameters:
nitroEnclaveEnabled
- If this parameter is set to true, the instance is enabled for AWS Nitro Enclaves;. This parameter is required.- Returns:
this
-
requireImdsv2
Whether IMDSv2 should be required on launched instances.Default: - false
- Parameters:
requireImdsv2
- Whether IMDSv2 should be required on launched instances. This parameter is required.- Returns:
this
-
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
. Note: You can provide an instanceProfile or a role, but not both.Default: - No new role is created.
Example:
Role role = Role.Builder.create(this, "MyRole") .assumedBy(new ServicePrincipal("ec2.amazonaws.com")) .build();
- Parameters:
role
- An IAM role to associate with the instance profile that is used by instances. This parameter is required.- Returns:
this
-
securityGroup
Security group to assign to instances created with the launch template.Default: No security group is assigned.
- Parameters:
securityGroup
- Security group to assign to instances created with the launch template. This parameter is required.- Returns:
this
-
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.Default: - Instance launched with this template will not be spot instances.
- Parameters:
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. This parameter is required.- Returns:
this
-
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
- Parameters:
userData
- The AMI that will be used by instances. This parameter is required.- Returns:
this
-
versionDescription
A description for the first version of the launch template.The version description must be maximum 255 characters long.
Default: - No description
- Parameters:
versionDescription
- A description for the first version of the launch template. This parameter is required.- Returns:
this
- See Also:
-
build
- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<LaunchTemplate>
- Returns:
- a newly built instance of
LaunchTemplate
.
-
keyPair
instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair