BlockDeviceVolume Class
Describes a block device mapping for an EC2 instance or Auto Scaling group.
| Source | aws-autoscaling/lib/volume.ts |
|---|
Example
ts
declare const vpc: ec2.Vpc;
declare const instanceType: ec2.InstanceType;
declare const machineImage: ec2.IMachineImage;
const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType,
machineImage,
blockDevices: [
{
deviceName: 'gp3-volume',
volume: autoscaling.BlockDeviceVolume.ebs(15, {
volumeType: autoscaling.EbsDeviceVolumeType.GP3,
throughput: 125,
}),
},
],
// ...
});
python
# vpc: ec2.Vpc
# instance_type: ec2.InstanceType
# machine_image: ec2.IMachineImage
auto_scaling_group = autoscaling.AutoScalingGroup(self, "ASG",
vpc=vpc,
instance_type=instance_type,
machine_image=machine_image,
block_devices=[autoscaling.BlockDevice(
device_name="gp3-volume",
volume=autoscaling.BlockDeviceVolume.ebs(15,
volume_type=autoscaling.EbsDeviceVolumeType.GP3,
throughput=125
)
)
]
)
java
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
AutoScalingGroup autoScalingGroup = AutoScalingGroup.Builder.create(this, "ASG")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
.blockDevices(List.of(BlockDevice.builder()
.deviceName("gp3-volume")
.volume(BlockDeviceVolume.ebs(15, EbsDeviceOptions.builder()
.volumeType(EbsDeviceVolumeType.GP3)
.throughput(125)
.build()))
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
var autoScalingGroup = new AutoScalingGroup(this, "ASG", new AutoScalingGroupProps {
Vpc = vpc,
InstanceType = instanceType,
MachineImage = machineImage,
BlockDevices = new [] { new BlockDevice {
DeviceName = "gp3-volume",
Volume = BlockDeviceVolume.Ebs(15, new EbsDeviceOptions {
VolumeType = EbsDeviceVolumeType.GP3,
Throughput = 125
})
} }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc
var instanceType InstanceType
var machineImage IMachineImage
autoScalingGroup := autoscaling.NewAutoScalingGroup(this, jsii.String("ASG"), &AutoScalingGroupProps{
Vpc: Vpc,
InstanceType: InstanceType,
MachineImage: MachineImage,
BlockDevices: []BlockDevice{
&BlockDevice{
DeviceName: jsii.String("gp3-volume"),
Volume: autoscaling.BlockDeviceVolume_Ebs(jsii.Number(15), &EbsDeviceOptions{
VolumeType: autoscaling.EbsDeviceVolumeType_GP3,
Throughput: jsii.Number(125),
}),
},
},
})
Properties
ebsDevicemay be undefinedEbsDevicePropsebs_devicemay be undefinedEbsDevicePropsebsDevicemay be undefinedEbsDevicePropsEbsDevicemay be undefinedEbsDevicePropsEbsDevicemay be undefinedEbsDeviceProps #EBS device info.
virtualNamemay be undefinedstringvirtual_namemay be undefinedstrvirtualNamemay be undefinedStringVirtualNamemay be undefinedstringVirtualNamemay be undefined*string #Virtual device name.
Methods
ebs(volumeSize: number, options?: EbsDeviceOptions): BlockDeviceVolume // chainable@staticmethod def ebs(volume_size: int | float, options: typing.Optional[EbsDeviceOptions] = None) -> BlockDeviceVolumepublic static BlockDeviceVolume ebs(Number volumeSize, EbsDeviceOptions options)public static BlockDeviceVolume Ebs(double volumeSize, EbsDeviceOptions? options = null)func Ebs(VolumeSize *float64, Options EbsDeviceOptions) BlockDeviceVolume static #Creates a new Elastic Block Storage device.
2 parameters
Parameters
volumeSizevolume_sizevolumeSizevolumeSizeVolumeSize— The volume size, in Gibibytes (GiB).optionsoptionsoptionsoptionsOptions— additional device options.
ebsFromSnapshot(snapshotId: string, options?: EbsDeviceSnapshotOptions): BlockDeviceVolume // chainable@staticmethod def ebs_from_snapshot(snapshot_id: str, options: typing.Optional[EbsDeviceSnapshotOptions] = None) -> BlockDeviceVolumepublic static BlockDeviceVolume ebsFromSnapshot(String snapshotId, EbsDeviceSnapshotOptions options)public static BlockDeviceVolume EbsFromSnapshot(string snapshotId, EbsDeviceSnapshotOptions? options = null)func EbsFromSnapshot(SnapshotId *string, Options EbsDeviceSnapshotOptions) BlockDeviceVolume static #Creates a new Elastic Block Storage device from an existing snapshot.
2 parameters
Parameters
snapshotIdsnapshot_idsnapshotIdsnapshotIdSnapshotId— The snapshot ID of the volume to use.optionsoptionsoptionsoptionsOptions— additional device options.
ephemeral(volumeIndex: number): BlockDeviceVolume // chainable@staticmethod def ephemeral(volume_index: int | float) -> BlockDeviceVolumepublic static BlockDeviceVolume ephemeral(Number volumeIndex)public static BlockDeviceVolume Ephemeral(double volumeIndex)func Ephemeral(VolumeIndex *float64) BlockDeviceVolume static #Creates a virtual, ephemeral device.
The name will be in the form ephemeral{volumeIndex}.
1 parameter
Parameters
volumeIndexvolume_indexvolumeIndexvolumeIndexVolumeIndex— the volume index.
noDevice(): BlockDeviceVolume // chainable@staticmethod def no_device() -> BlockDeviceVolumepublic static BlockDeviceVolume noDevice()public static BlockDeviceVolume NoDevice()func NoDevice() BlockDeviceVolume static #Suppresses a volume mapping.