Class Instance.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<Instance>
- Enclosing class:
Instance
Instance
.-
Method Summary
Modifier and TypeMethodDescriptionallowAllOutbound
(Boolean allowAllOutbound) Whether the instance could initiate connections to anywhere by default.availabilityZone
(String availabilityZone) In which AZ to place the instance within the VPC.blockDevices
(List<? extends BlockDevice> blockDevices) Specifies how block devices are exposed to the instance.build()
static Instance.Builder
detailedMonitoring
(Boolean detailedMonitoring) Whether "Detailed Monitoring" is enabled for this instance Keep in mind that Detailed Monitoring results in extra charges.init
(CloudFormationInit init) Apply the given CloudFormation Init configuration to the instance at startup.initOptions
(ApplyCloudFormationInitOptions initOptions) Use the given options for applying CloudFormation Init.instanceName
(String instanceName) The name of the instance.instanceType
(InstanceType instanceType) Type of instance to launch.Name of SSH keypair to grant access to instance.machineImage
(IMachineImage machineImage) AMI to launch.privateIpAddress
(String privateIpAddress) Defines a private IP address to associate with an instance.propagateTagsToVolumeOnCreation
(Boolean propagateTagsToVolumeOnCreation) Propagate the EC2 instance tags to the EBS volumes.requireImdsv2
(Boolean requireImdsv2) Whether IMDSv2 should be required on this instance.resourceSignalTimeout
(Duration resourceSignalTimeout) The length of time to wait for the resourceSignalCount.An IAM role to associate with the instance profile assigned to this Auto Scaling Group.securityGroup
(ISecurityGroup securityGroup) Security Group to assign to this instance.sourceDestCheck
(Boolean sourceDestCheck) Specifies whether to enable an instance launched in a VPC to perform NAT.Specific UserData to use.userDataCausesReplacement
(Boolean userDataCausesReplacement) Changes to the UserData force replacement.VPC to launch the instance in.vpcSubnets
(SubnetSelection vpcSubnets) Where to place the instance within the VPC.
-
Method Details
-
create
@Stability(Stable) public static Instance.Builder create(software.constructs.Construct scope, String id) - Parameters:
scope
- This parameter is required.id
- This parameter is required.- Returns:
- a new instance of
Instance.Builder
.
-
instanceType
Type of instance to launch.- Parameters:
instanceType
- Type of instance to launch. This parameter is required.- Returns:
this
-
machineImage
AMI to launch.- Parameters:
machineImage
- AMI to launch. This parameter is required.- Returns:
this
-
vpc
VPC to launch the instance in.- Parameters:
vpc
- VPC to launch the instance in. This parameter is required.- Returns:
this
-
allowAllOutbound
Whether the instance could initiate connections to anywhere by default.This property is only used when you do not provide a security group.
Default: true
- Parameters:
allowAllOutbound
- Whether the instance could initiate connections to anywhere by default. This parameter is required.- Returns:
this
-
availabilityZone
In which AZ to place the instance within the VPC.Default: - Random zone.
- Parameters:
availabilityZone
- In which AZ to place the instance within the VPC. This parameter is required.- Returns:
this
-
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:
-
detailedMonitoring
Whether "Detailed Monitoring" is enabled for this instance Keep in mind that Detailed Monitoring results in extra charges.Default: - false
- Parameters:
detailedMonitoring
- Whether "Detailed Monitoring" is enabled for this instance Keep in mind that Detailed Monitoring results in extra charges. This parameter is required.- Returns:
this
- See Also:
-
init
Apply the given CloudFormation Init configuration to the instance at startup.Default: - no CloudFormation init
- Parameters:
init
- Apply the given CloudFormation Init configuration to the instance at startup. This parameter is required.- Returns:
this
-
initOptions
Use the given options for applying CloudFormation Init.Describes the configsets to use and the timeout to wait
Default: - default options
- Parameters:
initOptions
- Use the given options for applying CloudFormation Init. This parameter is required.- Returns:
this
-
instanceName
The name of the instance.Default: - CDK generated name
- Parameters:
instanceName
- The name of the instance. This parameter is required.- Returns:
this
-
keyName
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
-
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.
Default: - no association
- Parameters:
privateIpAddress
- Defines a private IP address to associate with an instance. This parameter is required.- Returns:
this
-
propagateTagsToVolumeOnCreation
@Stability(Stable) public Instance.Builder propagateTagsToVolumeOnCreation(Boolean propagateTagsToVolumeOnCreation) Propagate the EC2 instance tags to the EBS volumes.Default: - false
- Parameters:
propagateTagsToVolumeOnCreation
- Propagate the EC2 instance tags to the EBS volumes. This parameter is required.- Returns:
this
-
requireImdsv2
Whether IMDSv2 should be required on this instance.Default: - false
- Parameters:
requireImdsv2
- Whether IMDSv2 should be required on this instance. This parameter is required.- Returns:
this
-
resourceSignalTimeout
The length of time to wait for the resourceSignalCount.The maximum value is 43200 (12 hours).
Default: Duration.minutes(5)
- Parameters:
resourceSignalTimeout
- The length of time to wait for the resourceSignalCount. This parameter is required.- Returns:
this
-
role
An IAM role to associate with the instance profile assigned to this Auto Scaling Group.The role must be assumable by the service principal
ec2.amazonaws.com
:Default: - A role will automatically be created, it can be accessed via the `role` property
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 assigned to this Auto Scaling Group. This parameter is required.- Returns:
this
-
securityGroup
Security Group to assign to this instance.Default: - create new security group
- Parameters:
securityGroup
- Security Group to assign to this instance. This parameter is required.- Returns:
this
-
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.
Default: true
- Parameters:
sourceDestCheck
- Specifies whether to enable an instance launched in a VPC to perform NAT. This parameter is required.- Returns:
this
-
userData
Specific UserData to use.The UserData may still be mutated after creation.
Default: - A UserData object appropriate for the MachineImage's Operating System is created.
- Parameters:
userData
- Specific UserData to use. This parameter is required.- Returns:
this
-
userDataCausesReplacement
@Stability(Stable) public Instance.Builder userDataCausesReplacement(Boolean 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.Default: - true iff `initOptions` is specified, false otherwise.
- Parameters:
userDataCausesReplacement
- Changes to the UserData force replacement. This parameter is required.- Returns:
this
-
vpcSubnets
Where to place the instance within the VPC.Default: - Private subnets.
- Parameters:
vpcSubnets
- Where to place the instance within the VPC. This parameter is required.- Returns:
this
-
build
-