Class Instance
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.ec2.Instance
- All Implemented Interfaces:
IConstruct,IDependable,IResource,IConnectable,IInstance,IGrantable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:39.395Z")
@Stability(Stable)
public class Instance
extends Resource
implements IInstance
This represents a single EC2 instance.
Example:
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
// ...
.blockDevices(List.of(BlockDevice.builder()
.deviceName("/dev/sda1")
.volume(BlockDeviceVolume.ebs(50))
.build(), BlockDevice.builder()
.deviceName("/dev/sdm")
.volume(BlockDeviceVolume.ebs(100))
.build()))
.build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.IInstance
IInstance.Jsii$Default, IInstance.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstance(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedInstance(software.amazon.jsii.JsiiObjectRef objRef) Instance(software.constructs.Construct scope, String id, InstanceProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSecurityGroup(ISecurityGroup securityGroup) Add the security group to the instance.voidaddToRolePolicy(PolicyStatement statement) Adds a statement to the IAM role assumed by the instance.voidaddUserData(@NotNull String... commands) Add command to the startup script of the instance.Allows specify security group connections for the instance.The principal to grant permissions to.the underlying instance resource.The availability zone the instance was launched in.The instance's ID.Private DNS name for this instance.Private IP for this instance.Publicly-routable DNS name for this instance.Publicly-routable IP address for this instance.The type of OS the instance is running.getRole()The IAM role assumed by the instance.UserData for the instance.Methods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.Construct
toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.core.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Instance
protected Instance(software.amazon.jsii.JsiiObjectRef objRef) -
Instance
protected Instance(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Instance
@Stability(Stable) public Instance(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull InstanceProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-
-
Method Details
-
addSecurityGroup
Add the security group to the instance.- Parameters:
securityGroup- : The security group to add. This parameter is required.
-
addToRolePolicy
Adds a statement to the IAM role assumed by the instance.- Parameters:
statement- This parameter is required.
-
addUserData
Add command to the startup script of the instance.The command must be in the scripting language supported by the instance's OS (i.e. Linux/Windows).
- Parameters:
commands- This parameter is required.
-
getConnections
Allows specify security group connections for the instance.- Specified by:
getConnectionsin interfaceIConnectable
-
getGrantPrincipal
The principal to grant permissions to.- Specified by:
getGrantPrincipalin interfaceIGrantable
-
getInstance
the underlying instance resource. -
getInstanceAvailabilityZone
The availability zone the instance was launched in.- Specified by:
getInstanceAvailabilityZonein interfaceIInstance
-
getInstanceId
The instance's ID.- Specified by:
getInstanceIdin interfaceIInstance
-
getInstancePrivateDnsName
Private DNS name for this instance.- Specified by:
getInstancePrivateDnsNamein interfaceIInstance
-
getInstancePrivateIp
Private IP for this instance.- Specified by:
getInstancePrivateIpin interfaceIInstance
-
getInstancePublicDnsName
Publicly-routable DNS name for this instance.(May be an empty string if the instance does not have a public name).
- Specified by:
getInstancePublicDnsNamein interfaceIInstance
-
getInstancePublicIp
Publicly-routable IP address for this instance.(May be an empty string if the instance does not have a public IP).
- Specified by:
getInstancePublicIpin interfaceIInstance
-
getOsType
The type of OS the instance is running. -
getRole
The IAM role assumed by the instance. -
getUserData
UserData for the instance.
-