# EbsDeviceProps

Properties of an EBS block device.

Extends: [EbsDeviceSnapshotOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.EbsDeviceSnapshotOptions.html), [EbsDeviceOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.EbsDeviceOptions.html)
Used as props by: [BlockDeviceVolume](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.BlockDeviceVolume.html)

- Source: [`aws-ec2/lib/volume.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-ec2/lib/volume.ts#L164)
- Type last changed: v2.11.0 · 8 Feb 2022

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_kms as kms } from 'aws-cdk-lib';

declare const key: kms.Key;
declare const size: cdk.Size;
const ebsDeviceProps: ec2.EbsDeviceProps = {
  deleteOnTermination: false,
  encrypted: false,
  iops: 123,
  kmsKey: key,
  snapshotId: 'snapshotId',
  throughput: 123,
  volumeInitializationRate: size,
  volumeSize: 123,
  volumeType: ec2.EbsDeviceVolumeType.STANDARD,
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_ec2 as ec2
from aws_cdk import aws_kms as kms

# key: kms.Key
# size: cdk.Size

ebs_device_props = ec2.EbsDeviceProps(
    delete_on_termination=False,
    encrypted=False,
    iops=123,
    kms_key=key,
    snapshot_id="snapshotId",
    throughput=123,
    volume_initialization_rate=size,
    volume_size=123,
    volume_type=ec2.EbsDeviceVolumeType.STANDARD
)
```

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.*;
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.kms.*;

Key key;
Size size;

EbsDeviceProps ebsDeviceProps = EbsDeviceProps.builder()
        .deleteOnTermination(false)
        .encrypted(false)
        .iops(123)
        .kmsKey(key)
        .snapshotId("snapshotId")
        .throughput(123)
        .volumeInitializationRate(size)
        .volumeSize(123)
        .volumeType(EbsDeviceVolumeType.STANDARD)
        .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;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.KMS;

Key key;
Size size;

var ebsDeviceProps = new EbsDeviceProps {
    DeleteOnTermination = false,
    Encrypted = false,
    Iops = 123,
    KmsKey = key,
    SnapshotId = "snapshotId",
    Throughput = 123,
    VolumeInitializationRate = size,
    VolumeSize = 123,
    VolumeType = EbsDeviceVolumeType.STANDARD
};
```

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 cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var key Key
var size Size

ebsDeviceProps := &EbsDeviceProps{
	DeleteOnTermination: jsii.Boolean(false),
	Encrypted: jsii.Boolean(false),
	Iops: jsii.Number(123),
	KmsKey: key,
	SnapshotId: jsii.String("snapshotId"),
	Throughput: jsii.Number(123),
	VolumeInitializationRate: size,
	VolumeSize: jsii.Number(123),
	VolumeType: awscdk.Aws_ec2.EbsDeviceVolumeType_STANDARD,
}
```

## Properties

- `deleteOnTermination`: boolean — Indicates whether to delete the volume when the instance is terminated.

  **Default:** true for Amazon EC2 Auto Scaling, false otherwise (e.g. EBS)

- `encrypted`: boolean = false — Specifies whether the EBS volume is encrypted.

  Encrypted EBS volumes can only be attached to instances that support Amazon EBS encryption

- `iops`: number — The number of I/O operations per second (IOPS) to provision for the volume.

  **Default:** none, required for `EbsDeviceVolumeType.IO1`

  Must only be set for `volumeType`: `EbsDeviceVolumeType.IO1`

  The maximum ratio of IOPS to volume size (in GiB) is 50:1, so for 5,000 provisioned IOPS,
  you need at least 100 GiB storage on the volume.

- `kmsKey`: [IKey](/cdk/api/v2/docs/aws-cdk-lib.aws_kms.IKey.html) — The ARN of the AWS Key Management Service (AWS KMS) CMK used for encryption.

  **Default:** If encrypted is true, the default aws/ebs KMS key will be used.

  You have to ensure that the KMS CMK has the correct permissions to be used by the service launching the ec2 instances.

- `snapshotId`: string — The snapshot ID of the volume to use.

  **Default:** No snapshot will be used

- `throughput`: number — The throughput to provision for a `gp3` volume.

  **Default:** 125 MiB/s.

  Valid Range: Minimum value of 125. Maximum value of 2000.

  `gp3` volumes deliver a consistent baseline throughput performance of 125 MiB/s.
  You can provision additional throughput for an additional cost at a ratio of 0.25 MiB/s per provisioned IOPS.

- `volumeInitializationRate`: [Size](/cdk/api/v2/docs/aws-cdk-lib.Size.html) — The Amazon EBS Provisioned Rate for Volume Initialization, at which to download the snapshot blocks from Amazon S3 to the volume.

  **Default:** undefined - The volume initialization rate is not set.

  Valid range is between 100 and 300 MiB/s.
  This parameter is supported only for volumes created from snapshots.

- `volumeSize`: number — The volume size, in Gibibytes (GiB).

  **Default:** The snapshot size

  If you specify volumeSize, it must be equal or greater than the size of the snapshot.

- `volumeType`: [EbsDeviceVolumeType](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.EbsDeviceVolumeType.html) — The EBS volume type.

  **Default:** `EbsDeviceVolumeType.GENERAL_PURPOSE_SSD` or `EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3` if `@aws-cdk/aws-ec2:ebsDefaultGp3Volume` is enabled.
