# BlockDevice

Block device.

Used as argument in: [ContainerRecipe.addInstanceBlockDevice](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-imagebuilder-alpha.ContainerRecipe.html#addinstanceblockdevice), ImageRecipe.addBlockDevice

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

## Example

TypeScript:

```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';

declare const blockDeviceVolume: ec2.BlockDeviceVolume;
const blockDevice: ec2.BlockDevice = {
  deviceName: 'deviceName',
  volume: blockDeviceVolume,

  // the properties below are optional
  mappingEnabled: false,
};
```

Python:

```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_volume: ec2.BlockDeviceVolume

block_device = ec2.BlockDevice(
    device_name="deviceName",
    volume=block_device_volume,

    # the properties below are optional
    mapping_enabled=False
)
```

Java:

```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.*;

BlockDeviceVolume blockDeviceVolume;

BlockDevice blockDevice = BlockDevice.builder()
        .deviceName("deviceName")
        .volume(blockDeviceVolume)

        // the properties below are optional
        .mappingEnabled(false)
        .build();
```

C# / .NET:

```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;

BlockDeviceVolume blockDeviceVolume;

var blockDevice = new BlockDevice {
    DeviceName = "deviceName",
    Volume = blockDeviceVolume,

    // the properties below are optional
    MappingEnabled = false
};
```

Golang:

```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"

var blockDeviceVolume BlockDeviceVolume

blockDevice := &BlockDevice{
	DeviceName: jsii.String("deviceName"),
	Volume: blockDeviceVolume,

	// the properties below are optional
	MappingEnabled: jsii.Boolean(false),
}
```

## Properties

- `deviceName`: string (required) — The device name exposed to the EC2 instance.

  For example, a value like `/dev/sdh`, `xvdh`.

- `mappingEnabled`: boolean — If false, the device mapping will be suppressed.

  **Default:** true - device mapping is left untouched

  If set to false for the root device, the instance might fail the Amazon EC2 health check.
  Amazon EC2 Auto Scaling launches a replacement instance if the instance fails the health check.

- `volume`: [BlockDeviceVolume](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.BlockDeviceVolume.html) (required) — Defines the block device volume, to be either an Amazon EBS volume or an ephemeral instance store volume.

  For example, a value like `BlockDeviceVolume.ebs(15)`, `BlockDeviceVolume.ephemeral(0)`.
