IVolume

class aws_cdk.aws_ec2.IVolume(*args, **kwargs)

Bases: aws_cdk.core.IResource, typing_extensions.Protocol

An EBS Volume in AWS EC2.

__init__(*args, **kwargs)

Methods

grant_attach_volume(grantee, instances=None)

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 {@link IVolume.grantAttachVolumeToSelf} to grant an instance permission to attach this volume to itself.

Parameters
  • grantee (IGrantable) – the principal being granted permission.

  • instances (Optional[List[IInstance]]) – the instances to which permission is being granted to attach this volume to. If not specified, then permission is granted to attach to all instances in this account.

Return type

Grant

grant_attach_volume_by_resource_tag(grantee, constructs, tag_key_suffix=None)

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.

If you need to call this method multiple times on different sets of constructs, then provide a unique tagKeySuffix for each call; failure to do so will result in an inability to attach this volume to some of the grants because it will overwrite the tag.

Parameters
  • grantee (IGrantable) – the principal being granted permission.

  • constructs (List[Construct]) – The list of constructs that will have the generated resource tag applied to them.

  • tag_key_suffix (Optional[str]) – A suffix to use on the generated Tag key in place of the generated hash value. Defaults to a hash calculated from this volume.

Return type

Grant

grant_detach_volume(grantee, instances=None)

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 {@link IVolume.grantDetachVolumeFromSelf} to grant an instance permission to detach this volume from itself.

Parameters
  • grantee (IGrantable) – the principal being granted permission.

  • instances (Optional[List[IInstance]]) – the instances to which permission is being granted to detach this volume from. If not specified, then permission is granted to detach from all instances in this account.

Return type

Grant

grant_detach_volume_by_resource_tag(grantee, constructs, tag_key_suffix=None)

Grants permission to detach the Volume by a ResourceTag condition.

This is implemented via the same mechanism as {@link IVolume.grantAttachVolumeByResourceTag}, and is subject to the same conditions.

Parameters
  • grantee (IGrantable) – the principal being granted permission.

  • constructs (List[Construct]) – The list of constructs that will have the generated resource tag applied to them.

  • tag_key_suffix (Optional[str]) – A suffix to use on the generated Tag key in place of the generated hash value. Defaults to a hash calculated from this volume.

Return type

Grant

Attributes

availability_zone

us-west-2a).

Type

The availability zone that the EBS Volume is contained within (ex

Return type

str

encryption_key

The customer-managed encryption key that is used to encrypt the Volume.

attribute: :attribute:: true

Return type

Optional[IKey]

node

The construct tree node for this construct.

Return type

ConstructNode

stack

The stack in which this resource is defined.

Return type

Stack

volume_id

The EBS Volume’s ID.

attribute: :attribute:: true

Return type

str