aws-cdk-lib.aws_ec2.BlockDeviceVolume

class BlockDeviceVolume

LanguageType name
.NETAmazon.CDK.AWS.EC2.BlockDeviceVolume
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#BlockDeviceVolume
Javasoftware.amazon.awscdk.services.ec2.BlockDeviceVolume
Pythonaws_cdk.aws_ec2.BlockDeviceVolume
TypeScript (source)aws-cdk-lib » aws_ec2 » BlockDeviceVolume

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

Example

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),
    },
  ],
});

Initializer (protected)

super(ebsDevice?: EbsDeviceProps, virtualName?: string)

Parameters

  • ebsDevice EbsDeviceProps — EBS device info.
  • virtualName string — Virtual device name.

Properties

NameTypeDescription
ebsDevice?EbsDevicePropsEBS device info.
virtualName?stringVirtual device name.

ebsDevice?

Type: EbsDeviceProps (optional)

EBS device info.


virtualName?

Type: string (optional)

Virtual device name.

Methods

NameDescription
static ebs(volumeSize, options?)Creates a new Elastic Block Storage device.
static ebsFromSnapshot(snapshotId, options?)Creates a new Elastic Block Storage device from an existing snapshot.
static ephemeral(volumeIndex)Creates a virtual, ephemeral device.

static ebs(volumeSize, options?)

public static ebs(volumeSize: number, options?: EbsDeviceOptions): BlockDeviceVolume

Parameters

  • volumeSize number — The volume size, in Gibibytes (GiB).
  • options EbsDeviceOptions — additional device options.

Returns

  • BlockDeviceVolume

Creates a new Elastic Block Storage device.


static ebsFromSnapshot(snapshotId, options?)

public static ebsFromSnapshot(snapshotId: string, options?: EbsDeviceSnapshotOptions): BlockDeviceVolume

Parameters

  • snapshotId string — The snapshot ID of the volume to use.
  • options EbsDeviceSnapshotOptions — additional device options.

Returns

  • BlockDeviceVolume

Creates a new Elastic Block Storage device from an existing snapshot.


static ephemeral(volumeIndex)

public static ephemeral(volumeIndex: number): BlockDeviceVolume

Parameters

  • volumeIndex number — the volume index.

Returns

  • BlockDeviceVolume

Creates a virtual, ephemeral device.

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