Class InstanceProps.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<InstanceProps>
- Enclosing interface:
InstanceProps
InstanceProps
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallowAllIpv6Outbound
(Boolean allowAllIpv6Outbound) Sets the value ofInstanceProps.getAllowAllIpv6Outbound()
allowAllOutbound
(Boolean allowAllOutbound) Sets the value ofInstanceProps.getAllowAllOutbound()
associatePublicIpAddress
(Boolean associatePublicIpAddress) Sets the value ofInstanceProps.getAssociatePublicIpAddress()
availabilityZone
(String availabilityZone) Sets the value ofInstanceProps.getAvailabilityZone()
blockDevices
(List<? extends BlockDevice> blockDevices) Sets the value ofInstanceProps.getBlockDevices()
build()
Builds the configured instance.creditSpecification
(CpuCredits creditSpecification) Sets the value ofInstanceProps.getCreditSpecification()
detailedMonitoring
(Boolean detailedMonitoring) Sets the value ofInstanceProps.getDetailedMonitoring()
ebsOptimized
(Boolean ebsOptimized) Sets the value ofInstanceProps.getEbsOptimized()
enclaveEnabled
(Boolean enclaveEnabled) Sets the value ofInstanceProps.getEnclaveEnabled()
hibernationEnabled
(Boolean hibernationEnabled) Sets the value ofInstanceProps.getHibernationEnabled()
init
(CloudFormationInit init) Sets the value ofInstanceProps.getInit()
initOptions
(ApplyCloudFormationInitOptions initOptions) Sets the value ofInstanceProps.getInitOptions()
instanceInitiatedShutdownBehavior
(InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior) Sets the value ofInstanceProps.getInstanceInitiatedShutdownBehavior()
instanceName
(String instanceName) Sets the value ofInstanceProps.getInstanceName()
instanceType
(InstanceType instanceType) Sets the value ofInstanceProps.getInstanceType()
ipv6AddressCount
(Number ipv6AddressCount) Sets the value ofInstanceProps.getIpv6AddressCount()
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 ofInstanceProps.getKeyPair()
machineImage
(IMachineImage machineImage) Sets the value ofInstanceProps.getMachineImage()
placementGroup
(IPlacementGroup placementGroup) Sets the value ofInstanceProps.getPlacementGroup()
privateIpAddress
(String privateIpAddress) Sets the value ofInstanceProps.getPrivateIpAddress()
propagateTagsToVolumeOnCreation
(Boolean propagateTagsToVolumeOnCreation) Sets the value ofInstanceProps.getPropagateTagsToVolumeOnCreation()
requireImdsv2
(Boolean requireImdsv2) Sets the value ofInstanceProps.getRequireImdsv2()
resourceSignalTimeout
(Duration resourceSignalTimeout) Sets the value ofInstanceProps.getResourceSignalTimeout()
Sets the value ofInstanceProps.getRole()
securityGroup
(ISecurityGroup securityGroup) Sets the value ofInstanceProps.getSecurityGroup()
sourceDestCheck
(Boolean sourceDestCheck) Sets the value ofInstanceProps.getSourceDestCheck()
ssmSessionPermissions
(Boolean ssmSessionPermissions) Sets the value ofInstanceProps.getSsmSessionPermissions()
Sets the value ofInstanceProps.getUserData()
userDataCausesReplacement
(Boolean userDataCausesReplacement) Sets the value ofInstanceProps.getUserDataCausesReplacement()
Sets the value ofInstanceProps.getVpc()
vpcSubnets
(SubnetSelection vpcSubnets) Sets the value ofInstanceProps.getVpcSubnets()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
instanceType
Sets the value ofInstanceProps.getInstanceType()
- Parameters:
instanceType
- Type of instance to launch. This parameter is required.- Returns:
this
-
machineImage
Sets the value ofInstanceProps.getMachineImage()
- Parameters:
machineImage
- AMI to launch. This parameter is required.- Returns:
this
-
vpc
Sets the value ofInstanceProps.getVpc()
- Parameters:
vpc
- VPC to launch the instance in. This parameter is required.- Returns:
this
-
allowAllIpv6Outbound
Sets the value ofInstanceProps.getAllowAllIpv6Outbound()
- Parameters:
allowAllIpv6Outbound
- Whether the instance could initiate IPv6 connections to anywhere by default. This property is only used when you do not provide a security group.- Returns:
this
-
allowAllOutbound
Sets the value ofInstanceProps.getAllowAllOutbound()
- Parameters:
allowAllOutbound
- Whether the instance could initiate connections to anywhere by default. This property is only used when you do not provide a security group.- Returns:
this
-
associatePublicIpAddress
@Stability(Stable) public InstanceProps.Builder associatePublicIpAddress(Boolean associatePublicIpAddress) Sets the value ofInstanceProps.getAssociatePublicIpAddress()
- Parameters:
associatePublicIpAddress
- Whether to associate a public IP address to the primary network interface attached to this instance. You cannot specify this property andipv6AddressCount
at the same time.- Returns:
this
-
availabilityZone
Sets the value ofInstanceProps.getAvailabilityZone()
- Parameters:
availabilityZone
- In which AZ to place the instance within the VPC.- Returns:
this
-
blockDevices
@Stability(Stable) public InstanceProps.Builder blockDevices(List<? extends BlockDevice> blockDevices) Sets the value ofInstanceProps.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
-
creditSpecification
Sets the value ofInstanceProps.getCreditSpecification()
- Parameters:
creditSpecification
- Specifying the CPU credit type for burstable EC2 instance types (T2, T3, T3a, etc). The unlimited CPU credit option is not supported for T3 instances with a dedicated host.- Returns:
this
-
detailedMonitoring
Sets the value ofInstanceProps.getDetailedMonitoring()
- Parameters:
detailedMonitoring
- Whether "Detailed Monitoring" is enabled for this instance Keep in mind that Detailed Monitoring results in extra charges.- Returns:
this
-
ebsOptimized
Sets the value ofInstanceProps.getEbsOptimized()
- Parameters:
ebsOptimized
- Indicates whether the instance is 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
-
enclaveEnabled
Sets the value ofInstanceProps.getEnclaveEnabled()
- Parameters:
enclaveEnabled
- Whether the instance is enabled for AWS Nitro Enclaves. Nitro Enclaves requires a Nitro-based virtualized parent instance with specific Intel/AMD with at least 4 vCPUs or Graviton with at least 2 vCPUs instance types and Linux/Windows host OS, while the enclave itself supports only Linux OS.You can't set both
enclaveEnabled
andhibernationEnabled
to true on the same instance.- Returns:
this
-
hibernationEnabled
Sets the value ofInstanceProps.getHibernationEnabled()
- Parameters:
hibernationEnabled
- Whether the instance is enabled for hibernation. You can't set bothenclaveEnabled
andhibernationEnabled
to true on the same instance.- Returns:
this
-
init
Sets the value ofInstanceProps.getInit()
- Parameters:
init
- Apply the given CloudFormation Init configuration to the instance at startup.- Returns:
this
-
initOptions
@Stability(Stable) public InstanceProps.Builder initOptions(ApplyCloudFormationInitOptions initOptions) Sets the value ofInstanceProps.getInitOptions()
- Parameters:
initOptions
- Use the given options for applying CloudFormation Init. Describes the configsets to use and the timeout to wait- Returns:
this
-
instanceInitiatedShutdownBehavior
@Stability(Stable) public InstanceProps.Builder instanceInitiatedShutdownBehavior(InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior) Sets the value ofInstanceProps.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
-
instanceName
Sets the value ofInstanceProps.getInstanceName()
- Parameters:
instanceName
- The name of the instance.- Returns:
this
-
ipv6AddressCount
Sets the value ofInstanceProps.getIpv6AddressCount()
- Parameters:
ipv6AddressCount
- The number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet.You cannot specify this property and
associatePublicIpAddress
at the same time.- 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 ofInstanceProps.getKeyName()
- Parameters:
keyName
- Name of SSH keypair to grant access to instance.- Returns:
this
-
keyPair
Sets the value ofInstanceProps.getKeyPair()
- Parameters:
keyPair
- The SSH keypair to grant access to the instance.- Returns:
this
-
placementGroup
Sets the value ofInstanceProps.getPlacementGroup()
- Parameters:
placementGroup
- The placement group that you want to launch the instance into.- Returns:
this
-
privateIpAddress
Sets the value ofInstanceProps.getPrivateIpAddress()
- Parameters:
privateIpAddress
- Defines a private IP address to associate with an instance. Private IP should be available within the VPC that the instance is build within.- Returns:
this
-
propagateTagsToVolumeOnCreation
@Stability(Stable) public InstanceProps.Builder propagateTagsToVolumeOnCreation(Boolean propagateTagsToVolumeOnCreation) Sets the value ofInstanceProps.getPropagateTagsToVolumeOnCreation()
- Parameters:
propagateTagsToVolumeOnCreation
- Propagate the EC2 instance tags to the EBS volumes.- Returns:
this
-
requireImdsv2
Sets the value ofInstanceProps.getRequireImdsv2()
- Parameters:
requireImdsv2
- Whether IMDSv2 should be required on this instance.- Returns:
this
-
resourceSignalTimeout
@Stability(Stable) public InstanceProps.Builder resourceSignalTimeout(Duration resourceSignalTimeout) Sets the value ofInstanceProps.getResourceSignalTimeout()
- Parameters:
resourceSignalTimeout
- The length of time to wait for the resourceSignalCount. The maximum value is 43200 (12 hours).- Returns:
this
-
role
Sets the value ofInstanceProps.getRole()
- Parameters:
role
- An IAM role to associate with the instance profile assigned to this Auto Scaling Group. The role must be assumable by the service principalec2.amazonaws.com
:- Returns:
this
-
securityGroup
Sets the value ofInstanceProps.getSecurityGroup()
- Parameters:
securityGroup
- Security Group to assign to this instance.- Returns:
this
-
sourceDestCheck
Sets the value ofInstanceProps.getSourceDestCheck()
- Parameters:
sourceDestCheck
- Specifies whether to enable an instance launched in a VPC to perform NAT. This controls whether source/destination checking is enabled on the instance. A value of true means that checking is enabled, and false means that checking is disabled. The value must be false for the instance to perform NAT.- Returns:
this
-
ssmSessionPermissions
@Stability(Stable) public InstanceProps.Builder ssmSessionPermissions(Boolean ssmSessionPermissions) Sets the value ofInstanceProps.getSsmSessionPermissions()
- Parameters:
ssmSessionPermissions
- Add SSM session permissions to the instance role. Setting this totrue
adds the necessary permissions to connect to the instance using SSM Session Manager. You can do this from the AWS Console.NOTE: Setting this flag to
true
may not be enough by itself. You must also use an AMI that comes with the SSM Agent, or install the SSM Agent yourself. See Working with SSM Agent in the SSM Developer Guide.- Returns:
this
-
userData
Sets the value ofInstanceProps.getUserData()
- Parameters:
userData
- Specific UserData to use. The UserData may still be mutated after creation.- Returns:
this
-
userDataCausesReplacement
@Stability(Stable) public InstanceProps.Builder userDataCausesReplacement(Boolean userDataCausesReplacement) Sets the value ofInstanceProps.getUserDataCausesReplacement()
- Parameters:
userDataCausesReplacement
- Changes to the UserData force replacement. Depending the EC2 instance type, changing UserData either restarts the instance or replaces the instance.- Instance store-backed instances are replaced.
- EBS-backed instances are restarted.
By default, restarting does not execute the new UserData so you will need a different mechanism to ensure the instance is restarted.
Setting this to
true
will make the instance's Logical ID depend on the UserData, which will cause CloudFormation to replace it if the UserData changes.- Returns:
this
-
vpcSubnets
Sets the value ofInstanceProps.getVpcSubnets()
- Parameters:
vpcSubnets
- Where to place the instance within the VPC.- Returns:
this
-
build
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<InstanceProps>
- Returns:
- a new instance of
InstanceProps
- Throws:
NullPointerException
- if any required attribute was not provided
-