Class LaunchTemplateProps.Builder
java.lang.Object
software.amazon.awscdk.services.ec2.LaunchTemplateProps.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<LaunchTemplateProps>
- Enclosing interface:
LaunchTemplateProps
@Stability(Stable)
public static final class LaunchTemplateProps.Builder
extends Object
implements software.amazon.jsii.Builder<LaunchTemplateProps>
A builder for
LaunchTemplateProps
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionassociatePublicIpAddress
(Boolean associatePublicIpAddress) Sets the value ofLaunchTemplateProps.getAssociatePublicIpAddress()
blockDevices
(List<? extends BlockDevice> blockDevices) Sets the value ofLaunchTemplateProps.getBlockDevices()
build()
Builds the configured instance.cpuCredits
(CpuCredits cpuCredits) Sets the value ofLaunchTemplateProps.getCpuCredits()
detailedMonitoring
(Boolean detailedMonitoring) Sets the value ofLaunchTemplateProps.getDetailedMonitoring()
disableApiTermination
(Boolean disableApiTermination) Sets the value ofLaunchTemplateProps.getDisableApiTermination()
ebsOptimized
(Boolean ebsOptimized) Sets the value ofLaunchTemplateProps.getEbsOptimized()
hibernationConfigured
(Boolean hibernationConfigured) Sets the value ofLaunchTemplateProps.getHibernationConfigured()
httpEndpoint
(Boolean httpEndpoint) Sets the value ofLaunchTemplateProps.getHttpEndpoint()
httpProtocolIpv6
(Boolean httpProtocolIpv6) Sets the value ofLaunchTemplateProps.getHttpProtocolIpv6()
httpPutResponseHopLimit
(Number httpPutResponseHopLimit) Sets the value ofLaunchTemplateProps.getHttpPutResponseHopLimit()
httpTokens
(LaunchTemplateHttpTokens httpTokens) Sets the value ofLaunchTemplateProps.getHttpTokens()
instanceInitiatedShutdownBehavior
(InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior) Sets the value ofLaunchTemplateProps.getInstanceInitiatedShutdownBehavior()
instanceMetadataTags
(Boolean instanceMetadataTags) Sets the value ofLaunchTemplateProps.getInstanceMetadataTags()
instanceProfile
(IInstanceProfile instanceProfile) Sets the value ofLaunchTemplateProps.getInstanceProfile()
instanceType
(InstanceType instanceType) Sets the value ofLaunchTemplateProps.getInstanceType()
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-pairSets the value ofLaunchTemplateProps.getKeyPair()
launchTemplateName
(String launchTemplateName) Sets the value ofLaunchTemplateProps.getLaunchTemplateName()
machineImage
(IMachineImage machineImage) Sets the value ofLaunchTemplateProps.getMachineImage()
nitroEnclaveEnabled
(Boolean nitroEnclaveEnabled) Sets the value ofLaunchTemplateProps.getNitroEnclaveEnabled()
requireImdsv2
(Boolean requireImdsv2) Sets the value ofLaunchTemplateProps.getRequireImdsv2()
Sets the value ofLaunchTemplateProps.getRole()
securityGroup
(ISecurityGroup securityGroup) Sets the value ofLaunchTemplateProps.getSecurityGroup()
spotOptions
(LaunchTemplateSpotOptions spotOptions) Sets the value ofLaunchTemplateProps.getSpotOptions()
Sets the value ofLaunchTemplateProps.getUserData()
versionDescription
(String versionDescription) Sets the value ofLaunchTemplateProps.getVersionDescription()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
associatePublicIpAddress
@Stability(Stable) public LaunchTemplateProps.Builder associatePublicIpAddress(Boolean associatePublicIpAddress) Sets the value ofLaunchTemplateProps.getAssociatePublicIpAddress()
- Parameters:
associatePublicIpAddress
- Whether instances should have a public IP addresses associated with them.- Returns:
this
-
blockDevices
@Stability(Stable) public LaunchTemplateProps.Builder blockDevices(List<? extends BlockDevice> blockDevices) Sets the value ofLaunchTemplateProps.getBlockDevices()
- Parameters:
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.- Returns:
this
-
cpuCredits
Sets the value ofLaunchTemplateProps.getCpuCredits()
- Parameters:
cpuCredits
- CPU credit type for burstable EC2 instance types.- Returns:
this
-
detailedMonitoring
@Stability(Stable) public LaunchTemplateProps.Builder detailedMonitoring(Boolean detailedMonitoring) Sets the value ofLaunchTemplateProps.getDetailedMonitoring()
- Parameters:
detailedMonitoring
- If set to true, then detailed monitoring will be enabled on instances created with this launch template.- Returns:
this
-
disableApiTermination
@Stability(Stable) public LaunchTemplateProps.Builder disableApiTermination(Boolean disableApiTermination) Sets the value ofLaunchTemplateProps.getDisableApiTermination()
- 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;. otherwise, you can.- Returns:
this
-
ebsOptimized
Sets the value ofLaunchTemplateProps.getEbsOptimized()
- Parameters:
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.- Returns:
this
-
hibernationConfigured
@Stability(Stable) public LaunchTemplateProps.Builder hibernationConfigured(Boolean hibernationConfigured) Sets the value ofLaunchTemplateProps.getHibernationConfigured()
- Parameters:
hibernationConfigured
- If you set this parameter to true, the instance is enabled for hibernation.- Returns:
this
-
httpEndpoint
Sets the value ofLaunchTemplateProps.getHttpEndpoint()
- Parameters:
httpEndpoint
- Enables or disables the HTTP metadata endpoint on your instances.- Returns:
this
-
httpProtocolIpv6
Sets the value ofLaunchTemplateProps.getHttpProtocolIpv6()
- Parameters:
httpProtocolIpv6
- Enables or disables the IPv6 endpoint for the instance metadata service.- Returns:
this
-
httpPutResponseHopLimit
@Stability(Stable) public LaunchTemplateProps.Builder httpPutResponseHopLimit(Number httpPutResponseHopLimit) Sets the value ofLaunchTemplateProps.getHttpPutResponseHopLimit()
- Parameters:
httpPutResponseHopLimit
- The desired HTTP PUT response hop limit for instance metadata requests. The larger the number, the further instance metadata requests can travel.- Returns:
this
-
httpTokens
@Stability(Stable) public LaunchTemplateProps.Builder httpTokens(LaunchTemplateHttpTokens httpTokens) Sets the value ofLaunchTemplateProps.getHttpTokens()
- Parameters:
httpTokens
- The state of token usage for your instance metadata requests. The default state isoptional
if not specified. However, if requireImdsv2 is true, the state must berequired
.- Returns:
this
-
instanceInitiatedShutdownBehavior
@Stability(Stable) public LaunchTemplateProps.Builder instanceInitiatedShutdownBehavior(InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior) Sets the value ofLaunchTemplateProps.getInstanceInitiatedShutdownBehavior()
- Parameters:
instanceInitiatedShutdownBehavior
- Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).- Returns:
this
-
instanceMetadataTags
@Stability(Stable) public LaunchTemplateProps.Builder instanceMetadataTags(Boolean instanceMetadataTags) Sets the value ofLaunchTemplateProps.getInstanceMetadataTags()
- Parameters:
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.- Returns:
this
-
instanceProfile
@Stability(Stable) public LaunchTemplateProps.Builder instanceProfile(IInstanceProfile instanceProfile) Sets the value ofLaunchTemplateProps.getInstanceProfile()
- Parameters:
instanceProfile
- The instance profile used to pass role information to EC2 instances. Note: You can provide an instanceProfile or a role, but not both.- Returns:
this
-
instanceType
Sets the value ofLaunchTemplateProps.getInstanceType()
- Parameters:
instanceType
- Type of instance to launch.- 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-pairSets the value ofLaunchTemplateProps.getKeyName()
- Parameters:
keyName
- Name of SSH keypair to grant access to instance.- Returns:
this
-
keyPair
Sets the value ofLaunchTemplateProps.getKeyPair()
- Parameters:
keyPair
- The SSH keypair to grant access to the instance.- Returns:
this
-
launchTemplateName
Sets the value ofLaunchTemplateProps.getLaunchTemplateName()
- Parameters:
launchTemplateName
- Name for this launch template.- Returns:
this
-
machineImage
Sets the value ofLaunchTemplateProps.getMachineImage()
- Parameters:
machineImage
- The AMI that will be used by instances.- Returns:
this
-
nitroEnclaveEnabled
@Stability(Stable) public LaunchTemplateProps.Builder nitroEnclaveEnabled(Boolean nitroEnclaveEnabled) Sets the value ofLaunchTemplateProps.getNitroEnclaveEnabled()
- Parameters:
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.- Returns:
this
-
requireImdsv2
Sets the value ofLaunchTemplateProps.getRequireImdsv2()
- Parameters:
requireImdsv2
- Whether IMDSv2 should be required on launched instances.- Returns:
this
-
role
Sets the value ofLaunchTemplateProps.getRole()
- Parameters:
role
- An IAM role to associate with the instance profile that is used by instances. The role must be assumable by the service principalec2.amazonaws.com
. Note: You can provide an instanceProfile or a role, but not both.- Returns:
this
-
securityGroup
Sets the value ofLaunchTemplateProps.getSecurityGroup()
- Parameters:
securityGroup
- Security group to assign to instances created with the launch template.- Returns:
this
-
spotOptions
@Stability(Stable) public LaunchTemplateProps.Builder spotOptions(LaunchTemplateSpotOptions spotOptions) Sets the value ofLaunchTemplateProps.getSpotOptions()
- 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.- Returns:
this
-
userData
Sets the value ofLaunchTemplateProps.getUserData()
- Parameters:
userData
- The AMI that will be used by instances.- Returns:
this
-
versionDescription
Sets the value ofLaunchTemplateProps.getVersionDescription()
- Parameters:
versionDescription
- A description for the first version of the launch template. The version description must be maximum 255 characters long.- Returns:
this
-
build
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<LaunchTemplateProps>
- Returns:
- a new instance of
LaunchTemplateProps
- Throws:
NullPointerException
- if any required attribute was not provided
-