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 classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.IInstance
IInstance.Jsii$Default, IInstance.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
Instance
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Instance
(software.amazon.jsii.JsiiObjectRef objRef) Instance
(software.constructs.Construct scope, String id, InstanceProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSecurityGroup
(ISecurityGroup securityGroup) Add the security group to the instance.void
addToRolePolicy
(PolicyStatement statement) Adds a statement to the IAM role assumed by the instance.void
addUserData
(@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, isResource
Methods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
Methods inherited from class software.constructs.Construct
toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.awscdk.core.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStack
Methods 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:
getConnections
in interfaceIConnectable
-
getGrantPrincipal
The principal to grant permissions to.- Specified by:
getGrantPrincipal
in interfaceIGrantable
-
getInstance
the underlying instance resource. -
getInstanceAvailabilityZone
The availability zone the instance was launched in.- Specified by:
getInstanceAvailabilityZone
in interfaceIInstance
-
getInstanceId
The instance's ID.- Specified by:
getInstanceId
in interfaceIInstance
-
getInstancePrivateDnsName
Private DNS name for this instance.- Specified by:
getInstancePrivateDnsName
in interfaceIInstance
-
getInstancePrivateIp
Private IP for this instance.- Specified by:
getInstancePrivateIp
in 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:
getInstancePublicDnsName
in 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:
getInstancePublicIp
in interfaceIInstance
-
getOsType
The type of OS the instance is running. -
getRole
The IAM role assumed by the instance. -
getUserData
UserData for the instance.
-