Skip to content
v2.278.0

IVolume Interface ​

An EBS Volume in AWS EC2.

Properties ​

availabilityZonestringavailability_zonestravailabilityZoneStringAvailabilityZonestringAvailabilityZone*string #
The availability zone that the EBS Volume is contained within (ex: us-west-2a).
encryptionKeymay be undefinedIKeyencryption_keymay be undefinedIKeyencryptionKeymay be undefinedIKeyEncryptionKeymay be undefinedIKeyEncryptionKeymay be undefinedIKey #
The customer-managed encryption key that is used to encrypt the Volume.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

nodeNodenodeNodenodeNodeNodeNodeNodeNode #
The tree node.
stackStackstackStackstackStackStackStackStackStack #
The stack in which this resource is defined.
volumeIdstringvolume_idstrvolumeIdStringVolumeIdstringVolumeId*string #
The EBS Volume's ID.
A reference to a Volume resource.

Methods ​

applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy) #
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

grantAttachVolume(grantee: IGrantable, instances?: IInstanceRef[]): Grantdef grant_attach_volume(self, grantee: IGrantable, instances: typing.Optional[typing.List[IInstanceRef]] = None) -> Grantpublic Grant grantAttachVolume(IGrantable grantee, List<IInstanceRef> instances)public Grant GrantAttachVolume(IGrantable grantee, IInstanceRef[]? instances = null)func GrantAttachVolume(Grantee IGrantable, Instances *[]IInstanceRef) Grant #
Grants permission to attach this Volume to an instance.
notes · 2 parameters

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.

Parameters

  • granteegranteegranteegranteeGrantee — the principal being granted permission.
  • instancesinstancesinstancesinstancesInstances — the instances to which permission is being granted to attach this volume to.
grantAttachVolumeByResourceTag(grantee: IGrantable, constructs: Construct[], tagKeySuffix?: string): Grantdef grant_attach_volume_by_resource_tag(self, grantee: IGrantable, constructs: typing.List[Construct], tag_key_suffix: typing.Optional[str] = None) -> Grantpublic Grant grantAttachVolumeByResourceTag(IGrantable grantee, List<Construct> constructs, String tagKeySuffix)public Grant GrantAttachVolumeByResourceTag(IGrantable grantee, Construct[] constructs, string? tagKeySuffix = null)func GrantAttachVolumeByResourceTag(Grantee IGrantable, Constructs *[]Construct, TagKeySuffix *string) Grant #
Grants permission to attach the Volume by a ResourceTag condition.
notes · 3 parameters

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.

Parameters

  • granteegranteegranteegranteeGrantee — the principal being granted permission.
  • constructsconstructsconstructsconstructsConstructs — The list of constructs that will have the generated resource tag applied to them.
  • tagKeySuffixtag_key_suffixtagKeySuffixtagKeySuffixTagKeySuffix — A suffix to use on the generated Tag key in place of the generated hash value.
grantDetachVolume(grantee: IGrantable, instances?: IInstanceRef[]): Grantdef grant_detach_volume(self, grantee: IGrantable, instances: typing.Optional[typing.List[IInstanceRef]] = None) -> Grantpublic Grant grantDetachVolume(IGrantable grantee, List<IInstanceRef> instances)public Grant GrantDetachVolume(IGrantable grantee, IInstanceRef[]? instances = null)func GrantDetachVolume(Grantee IGrantable, Instances *[]IInstanceRef) Grant #
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.

2 parameters

Parameters

  • granteegranteegranteegranteeGrantee — the principal being granted permission.
  • instancesinstancesinstancesinstancesInstances — the instances to which permission is being granted to detach this volume from.
grantDetachVolumeByResourceTag(grantee: IGrantable, constructs: Construct[], tagKeySuffix?: string): Grantdef grant_detach_volume_by_resource_tag(self, grantee: IGrantable, constructs: typing.List[Construct], tag_key_suffix: typing.Optional[str] = None) -> Grantpublic Grant grantDetachVolumeByResourceTag(IGrantable grantee, List<Construct> constructs, String tagKeySuffix)public Grant GrantDetachVolumeByResourceTag(IGrantable grantee, Construct[] constructs, string? tagKeySuffix = null)func GrantDetachVolumeByResourceTag(Grantee IGrantable, Constructs *[]Construct, TagKeySuffix *string) Grant #
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.

3 parameters

Parameters

  • granteegranteegranteegranteeGrantee — the principal being granted permission.
  • constructsconstructsconstructsconstructsConstructs — The list of constructs that will have the generated resource tag applied to them.
  • tagKeySuffixtag_key_suffixtagKeySuffixtagKeySuffixTagKeySuffix — A suffix to use on the generated Tag key in place of the generated hash value.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct #
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining