Class InstanceProps.Builder
java.lang.Object
software.amazon.awscdk.services.ec2.InstanceProps.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<InstanceProps>
- Enclosing interface:
InstanceProps
@Stability(Stable)
public static final class InstanceProps.Builder
extends Object
implements software.amazon.jsii.Builder<InstanceProps>
A builder for
InstanceProps
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallowAllOutbound
(Boolean allowAllOutbound) Sets the value ofInstanceProps.getAllowAllOutbound()
availabilityZone
(String availabilityZone) Sets the value ofInstanceProps.getAvailabilityZone()
blockDevices
(List<? extends BlockDevice> blockDevices) Sets the value ofInstanceProps.getBlockDevices()
build()
Builds the configured instance.detailedMonitoring
(Boolean detailedMonitoring) Sets the value ofInstanceProps.getDetailedMonitoring()
init
(CloudFormationInit init) Sets the value ofInstanceProps.getInit()
initOptions
(ApplyCloudFormationInitOptions initOptions) Sets the value ofInstanceProps.getInitOptions()
instanceName
(String instanceName) Sets the value ofInstanceProps.getInstanceName()
instanceType
(InstanceType instanceType) Sets the value ofInstanceProps.getInstanceType()
Sets the value ofInstanceProps.getKeyName()
machineImage
(IMachineImage machineImage) Sets the value ofInstanceProps.getMachineImage()
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()
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
-
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
-
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
-
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
-
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
-
instanceName
Sets the value ofInstanceProps.getInstanceName()
- Parameters:
instanceName
- The name of the instance.- Returns:
this
-
keyName
Sets the value ofInstanceProps.getKeyName()
- Parameters:
keyName
- Name of SSH keypair to grant access to instance.- 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
-
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
-