Skip to content
v2.278.0

BlockDeviceMappingProperty Struct ​

Specifies a block device mapping for a launch template.

You must specify DeviceName plus exactly one of the following properties: Ebs , NoDevice , or VirtualName .

BlockDeviceMapping is a property of AWS::EC2::LaunchTemplate LaunchTemplateData .

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
const blockDeviceMappingProperty: ec2.CfnLaunchTemplate.BlockDeviceMappingProperty = {
  deviceName: 'deviceName',
  ebs: {
    deleteOnTermination: false,
    ebsCardIndex: 123,
    encrypted: false,
    iops: 123,
    kmsKeyId: 'kmsKeyId',
    snapshotId: 'snapshotId',
    throughput: 123,
    volumeInitializationRate: 123,
    volumeSize: 123,
    volumeType: 'volumeType',
  },
  noDevice: 'noDevice',
  virtualName: 'virtualName',
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2

block_device_mapping_property = ec2.CfnLaunchTemplate.BlockDeviceMappingProperty(
    device_name="deviceName",
    ebs=ec2.CfnLaunchTemplate.EbsProperty(
        delete_on_termination=False,
        ebs_card_index=123,
        encrypted=False,
        iops=123,
        kms_key_id="kmsKeyId",
        snapshot_id="snapshotId",
        throughput=123,
        volume_initialization_rate=123,
        volume_size=123,
        volume_type="volumeType"
    ),
    no_device="noDevice",
    virtual_name="virtualName"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;

BlockDeviceMappingProperty blockDeviceMappingProperty = BlockDeviceMappingProperty.builder()
        .deviceName("deviceName")
        .ebs(EbsProperty.builder()
                .deleteOnTermination(false)
                .ebsCardIndex(123)
                .encrypted(false)
                .iops(123)
                .kmsKeyId("kmsKeyId")
                .snapshotId("snapshotId")
                .throughput(123)
                .volumeInitializationRate(123)
                .volumeSize(123)
                .volumeType("volumeType")
                .build())
        .noDevice("noDevice")
        .virtualName("virtualName")
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.EC2;

var blockDeviceMappingProperty = new BlockDeviceMappingProperty {
    DeviceName = "deviceName",
    Ebs = new EbsProperty {
        DeleteOnTermination = false,
        EbsCardIndex = 123,
        Encrypted = false,
        Iops = 123,
        KmsKeyId = "kmsKeyId",
        SnapshotId = "snapshotId",
        Throughput = 123,
        VolumeInitializationRate = 123,
        VolumeSize = 123,
        VolumeType = "volumeType"
    },
    NoDevice = "noDevice",
    VirtualName = "virtualName"
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

blockDeviceMappingProperty := &BlockDeviceMappingProperty{
	DeviceName: jsii.String("deviceName"),
	Ebs: &EbsProperty{
		DeleteOnTermination: jsii.Boolean(false),
		EbsCardIndex: jsii.Number(123),
		Encrypted: jsii.Boolean(false),
		Iops: jsii.Number(123),
		KmsKeyId: jsii.String("kmsKeyId"),
		SnapshotId: jsii.String("snapshotId"),
		Throughput: jsii.Number(123),
		VolumeInitializationRate: jsii.Number(123),
		VolumeSize: jsii.Number(123),
		VolumeType: jsii.String("volumeType"),
	},
	NoDevice: jsii.String("noDevice"),
	VirtualName: jsii.String("virtualName"),
}

Properties ​

deviceNameoptionalstringdevice_nameoptionalstrdeviceNameoptionalStringDeviceNameoptionalstringDeviceNameoptional*string #
The device name (for example, /dev/sdh or xvdh).
ebsoptionalIResolvable | CfnLaunchTemplate.EbsPropertyebsoptionaltyping.Union[IResolvable, EbsProperty]ebsoptionalIResolvableEbsoptionalIResolvableEbsoptionalinterface{} #
Parameters used to automatically set up EBS volumes when the instance is launched.
noDeviceoptionalstringno_deviceoptionalstrnoDeviceoptionalStringNoDeviceoptionalstringNoDeviceoptional*string #
To omit the device from the block device mapping, specify an empty string.
virtualNameoptionalstringvirtual_nameoptionalstrvirtualNameoptionalStringVirtualNameoptionalstringVirtualNameoptional*string #
The virtual device name (ephemeralN).
notes

Instance store volumes are numbered starting from 0. An instance type with 2 available instance store volumes can specify mappings for ephemeral0 and ephemeral1. The number of available instance store volumes depends on the instance type. After you connect to the instance, you must mount the volume.