Interface InstanceProps

All Superinterfaces:
All Known Implementing Classes:

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:39.401Z") @Stability(Stable) public interface InstanceProps extends
Properties of an EC2 Instance.


 Vpc vpc;
 InstanceType instanceType;
 IMachineImage machineImage;
 Instance.Builder.create(this, "Instance")
         // ...
                 .build(), BlockDevice.builder()
  • Method Details

    • getInstanceType

      @Stability(Stable) @NotNull InstanceType getInstanceType()
      Type of instance to launch.
    • getMachineImage

      @Stability(Stable) @NotNull IMachineImage getMachineImage()
      AMI to launch.
    • getVpc

      @Stability(Stable) @NotNull IVpc getVpc()
      VPC to launch the instance in.
    • getAllowAllOutbound

      @Stability(Stable) @Nullable default Boolean 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

    • getAvailabilityZone

      @Stability(Stable) @Nullable default String getAvailabilityZone()
      In which AZ to place the instance within the VPC.

      Default: - Random zone.

    • getBlockDevices

      @Stability(Stable) @Nullable default List<BlockDevice> 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:
    • getDetailedMonitoring

      @Stability(Stable) @Nullable default Boolean getDetailedMonitoring()
      Whether "Detailed Monitoring" is enabled for this instance Keep in mind that Detailed Monitoring results in extra charges.

      Default: - false

      See Also:
    • getInit

      @Stability(Stable) @Nullable default CloudFormationInit getInit()
      Apply the given CloudFormation Init configuration to the instance at startup.

      Default: - no CloudFormation init

    • getInitOptions

      @Stability(Stable) @Nullable default ApplyCloudFormationInitOptions getInitOptions()
      Use the given options for applying CloudFormation Init.

      Describes the configsets to use and the timeout to wait

      Default: - default options

    • getInstanceName

      @Stability(Stable) @Nullable default String getInstanceName()
      The name of the instance.

      Default: - CDK generated name

    • getKeyName

      @Stability(Stable) @Nullable default String getKeyName()
      Name of SSH keypair to grant access to instance.

      Default: - No SSH access will be possible.

    • getPrivateIpAddress

      @Stability(Stable) @Nullable default String 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

      @Stability(Stable) @Nullable default Boolean getPropagateTagsToVolumeOnCreation()
      Propagate the EC2 instance tags to the EBS volumes.

      Default: - false

    • getRequireImdsv2

      @Stability(Stable) @Nullable default Boolean getRequireImdsv2()
      Whether IMDSv2 should be required on this instance.

      Default: - false

    • getResourceSignalTimeout

      @Stability(Stable) @Nullable default Duration getResourceSignalTimeout()
      The length of time to wait for the resourceSignalCount.

      The maximum value is 43200 (12 hours).

      Default: Duration.minutes(5)

    • getRole

      @Stability(Stable) @Nullable default IRole 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

      Default: - A role will automatically be created, it can be accessed via the `role` property


       Role role = Role.Builder.create(this, "MyRole")
               .assumedBy(new ServicePrincipal(""))
    • getSecurityGroup

      @Stability(Stable) @Nullable default ISecurityGroup getSecurityGroup()
      Security Group to assign to this instance.

      Default: - create new security group

    • getSourceDestCheck

      @Stability(Stable) @Nullable default Boolean 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

    • getUserData

      @Stability(Stable) @Nullable default UserData 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

      @Stability(Stable) @Nullable default Boolean 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 iff `initOptions` is specified, false otherwise.

    • getVpcSubnets

      @Stability(Stable) @Nullable default SubnetSelection getVpcSubnets()
      Where to place the instance within the VPC.

      Default: - Private subnets.

    • builder

      @Stability(Stable) static InstanceProps.Builder builder()
      a InstanceProps.Builder of InstanceProps