Class Volume
- All Implemented Interfaces:
IResource
,IVolume
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
Example:
Instance instance; Role role; Volume volume = Volume.Builder.create(this, "Volume") .availabilityZone("us-west-2a") .size(Size.gibibytes(500)) .encrypted(true) .build(); volume.grantAttachVolume(role, List.of(instance));
-
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.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.IVolume
IVolume.Jsii$Default, IVolume.Jsii$Proxy
-
Constructor Summary
ModifierConstructorDescriptionprotected
Volume
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Volume
(software.amazon.jsii.JsiiObjectRef objRef) Volume
(software.constructs.Construct scope, String id, VolumeProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic IVolume
fromVolumeAttributes
(software.constructs.Construct scope, String id, VolumeAttributes attrs) Import an existing EBS Volume into the Stack.The availability zone that the EBS Volume is contained within (ex: us-west-2a).The customer-managed encryption key that is used to encrypt the Volume.The EBS Volume's ID.grantAttachVolume
(IGrantable grantee) Grants permission to attach this Volume to an instance.grantAttachVolume
(IGrantable grantee, List<IInstance> instances) Grants permission to attach this Volume to an instance.grantAttachVolumeByResourceTag
(IGrantable grantee, List<software.constructs.Construct> constructs) Grants permission to attach the Volume by a ResourceTag condition.grantAttachVolumeByResourceTag
(IGrantable grantee, List<software.constructs.Construct> constructs, String tagKeySuffix) Grants permission to attach the Volume by a ResourceTag condition.grantDetachVolume
(IGrantable grantee) Grants permission to detach this Volume from an instance CAUTION: Granting an instance permission to detach from itself using this method will lead to an unresolvable circular reference between the instance role and the instance.grantDetachVolume
(IGrantable grantee, List<IInstance> instances) Grants permission to detach this Volume from an instance CAUTION: Granting an instance permission to detach from itself using this method will lead to an unresolvable circular reference between the instance role and the instance.grantDetachVolumeByResourceTag
(IGrantable grantee, List<software.constructs.Construct> constructs) Grants permission to detach the Volume by a ResourceTag condition.grantDetachVolumeByResourceTag
(IGrantable grantee, List<software.constructs.Construct> constructs, String tagKeySuffix) Grants permission to detach the Volume by a ResourceTag condition.protected void
validateProps
(VolumeProps props) Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResource
Methods inherited from class software.constructs.Construct
getNode, isConstruct, 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.constructs.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Volume
protected Volume(software.amazon.jsii.JsiiObjectRef objRef) -
Volume
protected Volume(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Volume
@Stability(Stable) public Volume(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull VolumeProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
fromVolumeAttributes
@Stability(Stable) @NotNull public static IVolume fromVolumeAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull VolumeAttributes attrs) Import an existing EBS Volume into the Stack.- Parameters:
scope
- the scope of the import. This parameter is required.id
- the ID of the imported Volume in the construct tree. This parameter is required.attrs
- the attributes of the imported Volume. This parameter is required.
-
grantAttachVolume
@Stability(Stable) @NotNull public Grant grantAttachVolume(@NotNull IGrantable grantee, @Nullable List<IInstance> instances) Grants permission to attach this Volume to an instance.CAUTION: Granting an instance permission to attach to itself using this method will lead to an unresolvable circular reference between the instance role and the instance. Use
IVolume.grantAttachVolumeToSelf
to grant an instance permission to attach this volume to itself.- Specified by:
grantAttachVolume
in interfaceIVolume
- Parameters:
grantee
- This parameter is required.instances
-
-
grantAttachVolume
Grants permission to attach this Volume to an instance.CAUTION: Granting an instance permission to attach to itself using this method will lead to an unresolvable circular reference between the instance role and the instance. Use
IVolume.grantAttachVolumeToSelf
to grant an instance permission to attach this volume to itself.- Specified by:
grantAttachVolume
in interfaceIVolume
- Parameters:
grantee
- This parameter is required.
-
grantAttachVolumeByResourceTag
@Stability(Stable) @NotNull public Grant grantAttachVolumeByResourceTag(@NotNull IGrantable grantee, @NotNull List<software.constructs.Construct> constructs, @Nullable String tagKeySuffix) Grants permission to attach the Volume by a ResourceTag condition.If you are looking to grant an Instance, AutoScalingGroup, EC2-Fleet, SpotFleet, ECS host, etc the ability to attach this volume to itself then this is the method you want to use.
This is implemented by adding a Tag with key
VolumeGrantAttach-<suffix>
to the given constructs and this Volume, and then conditioning the Grant such that the grantee is only given the ability to AttachVolume if both the Volume and the destination Instance have that tag applied to them.- Specified by:
grantAttachVolumeByResourceTag
in interfaceIVolume
- Parameters:
grantee
- This parameter is required.constructs
- This parameter is required.tagKeySuffix
-
-
grantAttachVolumeByResourceTag
@Stability(Stable) @NotNull public Grant grantAttachVolumeByResourceTag(@NotNull IGrantable grantee, @NotNull List<software.constructs.Construct> constructs) Grants permission to attach the Volume by a ResourceTag condition.If you are looking to grant an Instance, AutoScalingGroup, EC2-Fleet, SpotFleet, ECS host, etc the ability to attach this volume to itself then this is the method you want to use.
This is implemented by adding a Tag with key
VolumeGrantAttach-<suffix>
to the given constructs and this Volume, and then conditioning the Grant such that the grantee is only given the ability to AttachVolume if both the Volume and the destination Instance have that tag applied to them.- Specified by:
grantAttachVolumeByResourceTag
in interfaceIVolume
- Parameters:
grantee
- This parameter is required.constructs
- This parameter is required.
-
grantDetachVolume
@Stability(Stable) @NotNull public Grant grantDetachVolume(@NotNull IGrantable grantee, @Nullable List<IInstance> instances) Grants permission to detach this Volume from an instance CAUTION: Granting an instance permission to detach from itself using this method will lead to an unresolvable circular reference between the instance role and the instance.Use
IVolume.grantDetachVolumeFromSelf
to grant an instance permission to detach this volume from itself.- Specified by:
grantDetachVolume
in interfaceIVolume
- Parameters:
grantee
- This parameter is required.instances
-
-
grantDetachVolume
Grants permission to detach this Volume from an instance CAUTION: Granting an instance permission to detach from itself using this method will lead to an unresolvable circular reference between the instance role and the instance.Use
IVolume.grantDetachVolumeFromSelf
to grant an instance permission to detach this volume from itself.- Specified by:
grantDetachVolume
in interfaceIVolume
- Parameters:
grantee
- This parameter is required.
-
grantDetachVolumeByResourceTag
@Stability(Stable) @NotNull public Grant grantDetachVolumeByResourceTag(@NotNull IGrantable grantee, @NotNull List<software.constructs.Construct> constructs, @Nullable String tagKeySuffix) Grants permission to detach the Volume by a ResourceTag condition.This is implemented via the same mechanism as
IVolume.grantAttachVolumeByResourceTag
, and is subject to the same conditions.- Specified by:
grantDetachVolumeByResourceTag
in interfaceIVolume
- Parameters:
grantee
- This parameter is required.constructs
- This parameter is required.tagKeySuffix
-
-
grantDetachVolumeByResourceTag
@Stability(Stable) @NotNull public Grant grantDetachVolumeByResourceTag(@NotNull IGrantable grantee, @NotNull List<software.constructs.Construct> constructs) Grants permission to detach the Volume by a ResourceTag condition.This is implemented via the same mechanism as
IVolume.grantAttachVolumeByResourceTag
, and is subject to the same conditions.- Specified by:
grantDetachVolumeByResourceTag
in interfaceIVolume
- Parameters:
grantee
- This parameter is required.constructs
- This parameter is required.
-
validateProps
- Parameters:
props
- This parameter is required.
-
getAvailabilityZone
The availability zone that the EBS Volume is contained within (ex: us-west-2a).- Specified by:
getAvailabilityZone
in interfaceIVolume
-
getVolumeId
The EBS Volume's ID.- Specified by:
getVolumeId
in interfaceIVolume
-
getEncryptionKey
The customer-managed encryption key that is used to encrypt the Volume.- Specified by:
getEncryptionKey
in interfaceIVolume
-