# Volume

Creates a new EBS Volume in AWS EC2.

Extends: Construct › Resource › Volume
Implements: IResource, IVolume, IEnvironmentAware, IVolumeRef, IConstruct, IDependable

- CloudFormation: [`AWS::EC2::Volume`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-ec2-volume.html)
- L1 type: [`CfnVolume`](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.CfnVolume.html)
- Source: [`aws-ec2/lib/volume.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ec2/lib/volume.ts#L662)
- Type last changed: v2.224.0 · 13 Nov 2025

## Example

```ts
new ec2.Volume(this, 'Volume', {
  availabilityZone: 'us-east-1a',
  size: Size.gibibytes(125),
  volumeType: ec2.EbsDeviceVolumeType.GP3,
  throughput: 125,
});
```

## Initializer

```ts
new Volume(scope: Construct, id: string, props: VolumeProps)
```

## Construct Props

- `autoEnableIo`: boolean = false — Indicates whether the volume is auto-enabled for I/O operations.

  By default, Amazon EBS disables I/O to the volume from attached EC2
  instances when it determines that a volume's data is potentially inconsistent. If the consistency of the volume is not a concern, and
  you prefer that the volume be made available immediately if it's impaired, you can configure the volume to automatically enable I/O.

- `availabilityZone`: string (required) — The Availability Zone in which to create the volume.

- `enableMultiAttach`: boolean = false — Indicates whether Amazon EBS Multi-Attach is enabled.

  See [Considerations and limitations](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volumes-multi.html#considerations)
  for the constraints of multi-attach.

- `encrypted`: boolean = false — Specifies whether the volume should be encrypted.

  The effect of setting the encryption state to true depends on the volume origin
  (new or from a snapshot), starting encryption state, ownership, and whether encryption by default is enabled. For more information,
  see [Encryption by Default](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html#encryption-by-default)
  in the Amazon Elastic Compute Cloud User Guide.

  Encrypted Amazon EBS volumes must be attached to instances that support Amazon EBS encryption. For more information, see
  [Supported Instance Types](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html#EBSEncryption_supported_instances).

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

  **Default:** The default KMS key for the account, region, and EC2 service is used.

  The encrypted property must
  be true if this is provided.

  Note: If using an `aws-kms.IKey` created from a `aws-kms.Key.fromKeyArn()` here,
  then the KMS key **must** have the following in its Key policy; otherwise, the Volume
  will fail to create.

      {
        "Effect": "Allow",
        "Principal": { "AWS": "<arn for your account-user> ex: arn:aws:iam::00000000000:root" },
        "Resource": "*",
        "Action": [
          "kms:DescribeKey",
          "kms:GenerateDataKeyWithoutPlainText",
        ],
        "Condition": {
          "StringEquals": {
            "kms:ViaService": "ec2.<Region>.amazonaws.com", (eg: ec2.us-east-1.amazonaws.com)
            "kms:CallerAccount": "0000000000" (your account ID)
          }
        }
      }

- `iops`: number — The number of I/O operations per second (IOPS) to provision for the volume.

  **Default:** None -- Required for io1 and io2 volumes. The default for gp3 volumes is 3,000 IOPS if omitted.

  The maximum ratio is 50 IOPS/GiB for PROVISIONED_IOPS_SSD,
  and 500 IOPS/GiB for both PROVISIONED_IOPS_SSD_IO2 and GENERAL_PURPOSE_SSD_GP3.
  See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-volume.html
  for more information.

  This parameter is valid only for PROVISIONED_IOPS_SSD, PROVISIONED_IOPS_SSD_IO2 and GENERAL_PURPOSE_SSD_GP3 volumes.

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.RETAIN — Policy to apply when the volume is removed from the stack.

- `size`: [Size](/cdk/api/v2/docs/aws-cdk-lib.Size.html) — The size of the volume, in GiBs.

  **Default:** If you're creating the volume from a snapshot and don't specify a volume size, the default is the snapshot size.

  You must specify either a snapshot ID or a volume size.
  See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-volume.html
  for details on the allowable size for each type of volume.

- `snapshotId`: string — The snapshot from which to create the volume.

  **Default:** The EBS volume is not created from a snapshot.

  You must specify either a snapshot ID or a volume size.

- `throughput`: number — The throughput that the volume supports, in MiB/s Takes a minimum of 125 and maximum of 2000.

  **Default:** 125 MiB/s. Only valid on gp3 volumes.

- `volumeInitializationRate`: [Size](/cdk/api/v2/docs/aws-cdk-lib.Size.html) — Specifies the Amazon EBS Provisioned Rate for Volume Initialization (volume initialization rate), at which to download the snapshot blocks from Amazon S3 to the volume.

  **Default:** undefined - The volume initialization rate is not set.

  Valid range is between 100 and 300 MiB/s.

  This parameter is supported only for volumes created from snapshots.

- `volumeName`: string — The value of the physicalName property of this resource.

  **Default:** The physical name will be allocated by CloudFormation at deployment time

- `volumeType`: [EbsDeviceVolumeType](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.EbsDeviceVolumeType.html) — The type of the volume;

  **Default:** `EbsDeviceVolumeType.GENERAL_PURPOSE_SSD`

  what type of storage to use to form the EBS Volume.

## Properties

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

- `encryptionKey`: [IKey](/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](/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](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `stack`: [Stack](/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](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_ec2.VolumeReference.html) — A reference to a Volume resource.

## Methods

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

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

- `fromVolumeAttributes(scope: Construct, id: string, attrs: VolumeAttributes): IVolume` (static) — Import an existing EBS Volume into the Stack.

  **Parameters**

  - `scope` — the scope of the import.
  - `id` — the ID of the imported Volume in the construct tree.
  - `attrs` — the attributes of the imported Volume.

- `grantAttachVolume(grantee: IGrantable, instances?: IInstanceRef[]): Grant` — [disable-awslint:no-grants].

- `grantAttachVolumeByResourceTag(grantee: IGrantable, constructs: Construct[], tagKeySuffix?: string): Grant` — [disable-awslint:no-grants].

- `grantDetachVolume(grantee: IGrantable, instances?: IInstanceRef[]): Grant` — [disable-awslint:no-grants].

- `grantDetachVolumeByResourceTag(grantee: IGrantable, constructs: Construct[], tagKeySuffix?: string): Grant` — [disable-awslint:no-grants].

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `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.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
