Interface InstanceProps
- All Superinterfaces:
software.amazon.jsii.JsiiSerializable
- All Known Implementing Classes:
InstanceProps.Jsii$Proxy
Example:
IVpc vpc; LoadBalancer lb = LoadBalancer.Builder.create(this, "LB") .vpc(vpc) .internetFacing(true) .build(); // instance to add as the target for load balancer. Instance instance = Instance.Builder.create(this, "targetInstance") .vpc(vpc) .instanceType(InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.MICRO)) .machineImage(AmazonLinuxImage.Builder.create().generation(AmazonLinuxGeneration.AMAZON_LINUX_2).build()) .build(); lb.addTarget(new InstanceTarget(instance));
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class
A builder forInstanceProps
static final class
An implementation forInstanceProps
-
Method Summary
Modifier and TypeMethodDescriptionstatic InstanceProps.Builder
builder()
default Boolean
Whether the instance could initiate IPv6 connections to anywhere by default.default Boolean
Whether the instance could initiate connections to anywhere by default.default Boolean
Whether to associate a public IP address to the primary network interface attached to this instance.default String
In which AZ to place the instance within the VPC.default List<BlockDevice>
Specifies how block devices are exposed to the instance.default CpuCredits
Specifying the CPU credit type for burstable EC2 instance types (T2, T3, T3a, etc).default Boolean
Whether "Detailed Monitoring" is enabled for this instance Keep in mind that Detailed Monitoring results in extra charges.default Boolean
If true, the instance will not be able to be terminated using the Amazon EC2 console, CLI, or API.default Boolean
Indicates whether the instance is optimized for Amazon EBS I/O.default Boolean
Whether the instance is enabled for AWS Nitro Enclaves.default Boolean
Whether the instance is enabled for hibernation.default CloudFormationInit
getInit()
Apply the given CloudFormation Init configuration to the instance at startup.default ApplyCloudFormationInitOptions
Use the given options for applying CloudFormation Init.Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).default String
The name of the instance.default IInstanceProfile
The instance profile used to pass role information to EC2 instances.Type of instance to launch.default Number
The number of IPv6 addresses to associate with the primary network interface.default String
Deprecated.default IKeyPair
The SSH keypair to grant access to the instance.AMI to launch.default IPlacementGroup
The placement group that you want to launch the instance into.default String
Defines a private IP address to associate with an instance.default Boolean
Propagate the EC2 instance tags to the EBS volumes.default Boolean
Whether IMDSv2 should be required on this instance.default Duration
The length of time to wait for the resourceSignalCount.default IRole
getRole()
An IAM role to associate with the instance profile assigned to this Auto Scaling Group.default ISecurityGroup
Security Group to assign to this instance.default Boolean
Specifies whether to enable an instance launched in a VPC to perform NAT.default Boolean
Add SSM session permissions to the instance role.default UserData
Specific UserData to use.default Boolean
Changes to the UserData force replacement.getVpc()
VPC to launch the instance in.default SubnetSelection
Where to place the instance within the VPC.Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Method Details
-
getInstanceType
Type of instance to launch. -
getMachineImage
AMI to launch. -
getVpc
VPC to launch the instance in. -
getAllowAllIpv6Outbound
Whether the instance could initiate IPv6 connections to anywhere by default.This property is only used when you do not provide a security group.
Default: false
-
getAllowAllOutbound
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
-
getAssociatePublicIpAddress
Whether to associate a public IP address to the primary network interface attached to this instance.You cannot specify this property and
ipv6AddressCount
at the same time.Default: - public IP address is automatically assigned based on default behavior
-
getAvailabilityZone
In which AZ to place the instance within the VPC.Default: - Random zone.
-
getBlockDevices
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
- See Also:
-
getCreditSpecification
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.
Default: - T2 instances are standard, while T3, T4g, and T3a instances are unlimited.
-
getDetailedMonitoring
Whether "Detailed Monitoring" is enabled for this instance Keep in mind that Detailed Monitoring results in extra charges.Default: - false
- See Also:
-
getDisableApiTermination
If true, the instance will not be able to be terminated using the Amazon EC2 console, CLI, or API.To change this attribute after launch, use ModifyInstanceAttribute. Alternatively, if you set InstanceInitiatedShutdownBehavior to terminate, you can terminate the instance by running the shutdown command from the instance.
Default: false
- See Also:
-
getEbsOptimized
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.
Default: false
-
getEnclaveEnabled
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.Default: - false
- See Also:
-
getHibernationEnabled
Whether the instance is enabled for hibernation.You can't set both
enclaveEnabled
andhibernationEnabled
to true on the same instance.Default: - false
- See Also:
-
getInit
Apply the given CloudFormation Init configuration to the instance at startup.Default: - no CloudFormation init
-
getInitOptions
Use the given options for applying CloudFormation Init.Describes the configsets to use and the timeout to wait
Default: - default options
-
getInstanceInitiatedShutdownBehavior
@Stability(Stable) @Nullable default InstanceInitiatedShutdownBehavior getInstanceInitiatedShutdownBehavior()Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).Default: InstanceInitiatedShutdownBehavior.STOP
- See Also:
-
getInstanceName
The name of the instance.Default: - CDK generated name
-
getInstanceProfile
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
-
getIpv6AddressCount
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.Default: - For instances associated with an IPv6 subnet, use 1; otherwise, use 0.
-
getKeyName
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.
- Use
-
getKeyPair
The SSH keypair to grant access to the instance.Default: - No SSH access will be possible.
-
getPlacementGroup
The placement group that you want to launch the instance into.Default: - no placement group will be used for this instance.
-
getPrivateIpAddress
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
-
getPropagateTagsToVolumeOnCreation
Propagate the EC2 instance tags to the EBS volumes.Default: - false
-
getRequireImdsv2
Whether IMDSv2 should be required on this instance.Default: - false
-
getResourceSignalTimeout
The length of time to wait for the resourceSignalCount.The maximum value is 43200 (12 hours).
Default: Duration.minutes(5)
-
getRole
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
: Note: You can provide an instanceProfile or a role, but not both.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();
-
getSecurityGroup
Security Group to assign to this instance.Default: - create new security group
-
getSourceDestCheck
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
-
getSsmSessionPermissions
Add SSM session permissions to the instance role.Setting this to
true
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.Default: false
-
getUserData
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.
-
getUserDataCausesReplacement
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 if `initOptions` is specified, false otherwise.
-
getVpcSubnets
Where to place the instance within the VPC.Default: - Private subnets.
-
builder
- Returns:
- a
InstanceProps.Builder
ofInstanceProps
-
keyPair
instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair