# BlockDeviceVolume

Describes a block device mapping for an EC2 instance or Auto Scaling group.

- Source: [`aws-ec2/lib/volume.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-ec2/lib/volume.ts#L176)

## Example

```ts
declare const vpc: ec2.Vpc;
declare const instanceType: ec2.InstanceType;
declare const machineImage: ec2.IMachineImage;

new ec2.Instance(this, 'Instance', {
  vpc,
  instanceType,
  machineImage,

  // ...

  blockDevices: [
    {
      deviceName: '/dev/sda1',
      volume: ec2.BlockDeviceVolume.ebs(50),
    },
    {
      deviceName: '/dev/sdm',
      volume: ec2.BlockDeviceVolume.ebs(100),
    },
  ],
});
```

## Properties

- `ebsDevice`: [EbsDeviceProps](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.EbsDeviceProps.html) — EBS device info.

- `virtualName`: string — Virtual device name.

## Methods

- `ebs(volumeSize: number, options?: EbsDeviceOptions): BlockDeviceVolume // chainable` (static) — Creates a new Elastic Block Storage device.

  **Parameters**

  - `volumeSize` — The volume size, in Gibibytes (GiB).
  - `options` — additional device options.

- `ebsFromSnapshot(snapshotId: string, options?: EbsDeviceSnapshotOptions): BlockDeviceVolume // chainable` (static) — Creates a new Elastic Block Storage device from an existing snapshot.

  **Parameters**

  - `snapshotId` — The snapshot ID of the volume to use.
  - `options` — additional device options.

- `ephemeral(volumeIndex: number): BlockDeviceVolume // chainable` (static) — Creates a virtual, ephemeral device.

  The name will be in the form ephemeral{volumeIndex}.

  **Parameters**

  - `volumeIndex` — the volume index.
