# IVolume

An EBS Volume in AWS EC2.

Extends: [IResource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResource.html), [IVolumeRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_ec2.IVolumeRef.html)
Implemented by: [Volume](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Volume.html)
Obtainable from: [Volume.fromVolumeAttributes](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Volume.html#fromvolumeattributes)

- Source: [`aws-ec2/lib/volume.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ec2/lib/volume.ts#L298)
- Type last changed: v2.224.0 · 13 Nov 2025

## Properties

- `availabilityZone`: string — The availability zone that the EBS Volume is contained within (ex: us-west-2a).

- `encryptionKey`: [IKey](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kms.IKey.html) — The customer-managed encryption key that is used to encrypt the Volume.

- `env`: [ResourceEnvironment](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  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.

- `node`: [Node](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `stack`: [Stack](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

- `volumeId`: string — The EBS Volume's ID.

- `volumeRef`: [VolumeReference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_ec2.VolumeReference.html) — A reference to a Volume resource.

## Methods

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  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[]): Grant` — 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.

  **Parameters**

  - `grantee` — the principal being granted permission.
  - `instances` — the instances to which permission is being granted to attach this volume to.

- `grantAttachVolumeByResourceTag(grantee: IGrantable, constructs: Construct[], tagKeySuffix?: string): Grant` — 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.

  **Parameters**

  - `grantee` — the principal being granted permission.
  - `constructs` — The list of constructs that will have the generated resource tag applied to them.
  - `tagKeySuffix` — A suffix to use on the generated Tag key in place of the generated hash value.

- `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.

  **Parameters**

  - `grantee` — the principal being granted permission.
  - `instances` — the instances to which permission is being granted to detach this volume from.

- `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.

  **Parameters**

  - `grantee` — the principal being granted permission.
  - `constructs` — The list of constructs that will have the generated resource tag applied to them.
  - `tagKeySuffix` — A suffix to use on the generated Tag key in place of the generated hash value.

- `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.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
