AWS CloudFormation
User Guide (Version )

AWS::EC2::Volume

Specifies an Amazon Elastic Block Store (Amazon EBS) volume.

When you use AWS CloudFormation to update an Amazon EBS volume that modifies Iops, Size, or VolumeType, there is a cooldown period before another operation can occur. This can cause your stack to report being in UPDATE_IN_PROGRESS or UPDATE_ROLLBACK_IN_PROGRESS for long periods of time.

Amazon EBS does not support modifying a Magnetic volume. For more information, see Requirements for Modifying EBS Volumes.

Amazon EBS does not support sizing down an Amazon EBS volume. AWS CloudFormation will not attempt to modify an Amazon EBS volume to a smaller size on rollback.

Some common scenarios when you might encounter a cooldown period for Amazon EBS include:

  • You successfully update an Amazon EBS volume and the update succeeds. When you attempt another update within the cooldown window, that update will be subject to a cooldown period.

  • You successfully update an Amazon EBS volume and the update succeeds but another change in your update-stack call fails. The rollback will be subject to a cooldown period.

For more information on the cooldown period, see Requirements for Modifying EBS Volumes.

To control how AWS CloudFormation handles the volume when the stack is deleted, set a deletion policy for your volume. You can choose to retain the volume, to delete the volume, or to create a snapshot of the volume. For more information, see DeletionPolicy Attribute.

Note

If you set a deletion policy that creates a snapshot, all tags on the volume are included in the snapshot.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::EC2::Volume", "Properties" : { "AutoEnableIO" : Boolean, "AvailabilityZone" : String, "Encrypted" : Boolean, "Iops" : Integer, "KmsKeyId" : String, "Size" : Integer, "SnapshotId" : String, "Tags" : [ Tag, ... ], "VolumeType" : String } }

YAML

Type: AWS::EC2::Volume Properties: AutoEnableIO: Boolean AvailabilityZone: String Encrypted: Boolean Iops: Integer KmsKeyId: String Size: Integer SnapshotId: String Tags: - Tag VolumeType: String

Properties

AutoEnableIO

Indicates whether the volume is auto-enabled for I/O operations. By default, Amazon EBS disables I/O to the volume from attached EC2 instances when it determines that a volume's data is potentially inconsistent. If the consistency of the volume is not a concern, and you prefer that the volume be made available immediately if it's impaired, you can configure the volume to automatically enable I/O.

Required: No

Type: Boolean

Update requires: No interruption

AvailabilityZone

The Availability Zone in which to create the volume.

Required: Yes

Type: String

Update requires: No interruption

Encrypted

Specifies whether the volume should be encrypted. The effect of setting the encryption state to true depends on the volume origin (new or from a snapshot), starting encryption state, ownership, and whether encryption by default is enabled. For more information, see Encryption by Default in the Amazon Elastic Compute Cloud User Guide.

Encrypted Amazon EBS volumes must be attached to instances that support Amazon EBS encryption. For more information, see Supported Instance Types.

Required: No

Type: Boolean

Update requires: No interruption

Iops

The number of I/O operations per second (IOPS) to provision for the volume, with a maximum ratio of 50 IOPS/GiB. Range is 100 to 64,000 IOPS for volumes in most Regions. Maximum IOPS of 64,000 is guaranteed only on Nitro-based instances. Other instance families guarantee performance up to 32,000 IOPS. For more information, see Amazon EBS Volume Types in the Amazon Elastic Compute Cloud User Guide.

This parameter is valid only for Provisioned IOPS SSD (io1) volumes.

Required: No

Type: Integer

Update requires: No interruption

KmsKeyId

The identifier of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use for Amazon EBS encryption. If this parameter is not specified, your AWS managed CMK for EBS is used. If KmsKeyId is specified, the encrypted state must be true.

You can specify the CMK using any of the following:

  • Key ID. For example, key/1234abcd-12ab-34cd-56ef-1234567890ab.

  • Key alias. For example, alias/ExampleAlias.

  • Key ARN. For example, arn:aws:kms:us-east-1:012345678910:key/abcd1234-a123-456a-a12b-a123b4cd56ef.

  • Alias ARN. For example, arn:aws:kms:us-east-1:012345678910:alias/ExampleAlias.

AWS authenticates the CMK asynchronously. Therefore, if you specify an ID, alias, or ARN that is not valid, the action can appear to complete, but eventually fails.

Required: No

Type: String

Update requires: No interruption

Size

The size of the volume, in GiBs.

Constraints: 1-16,384 for gp2, 4-16,384 for io1, 500-16,384 for st1, 500-16,384 for sc1, and 1-1,024 for standard. If you specify a snapshot, the volume size must be equal to or larger than the snapshot size.

Default: If you're creating the volume from a snapshot and don't specify a volume size, the default is the snapshot size.

Note

At least one of Size or SnapshotId is required.

Required: No

Type: Integer

Update requires: No interruption

SnapshotId

The snapshot from which to create the volume.

Note

At least one of Size or SnapshotId are required.

Required: No

Type: String

Update requires: No interruption

Tags

The tags to apply to the volume during creation.

Required: No

Type: List of Tag

Update requires: No interruption

VolumeType

The volume type. This can be gp2 for General Purpose SSD, io1 for Provisioned IOPS SSD, st1 for Throughput Optimized HDD, sc1 for Cold HDD, or standard for Magnetic volumes.

Defaults: If no volume type is specified, the default is standard in us-east-1, eu-west-1, eu-central-1, us-west-2, us-west-1, sa-east-1, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, us-gov-west-1, and cn-north-1. In all other Regions, EBS defaults to gp2.

Required: No

Type: String

Allowed Values: gp2 | io1 | sc1 | st1 | standard

Update requires: No interruption

Return Values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the resource name. For example: vol-5cb85026.

For more information about using the Ref function, see Ref.

Examples

Encrypted Amazon EBS Volume with DeletionPolicy to Make a Snapshot on Delete

JSON

"NewVolume" : { "Type" : "AWS::EC2::Volume", "Properties" : { "Size" : "100", "Encrypted" : "true", "AvailabilityZone" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] }, "Tags" : [ { "Key" : "MyTag", "Value" : "TagValue" } ] }, "DeletionPolicy" : "Snapshot" }

YAML

NewVolume: Type: AWS::EC2::Volume Properties: Size: 100 Encrypted: true AvailabilityZone: !GetAtt Ec2Instance.AvailabilityZone Tags: - Key: MyTag Value: TagValue DeletionPolicy: Snapshot

Amazon EBS Volume with 100 Provisioned IOPS

JSON

"NewVolume" : { "Type" : "AWS::EC2::Volume", "Properties" : { "Size" : "100", "VolumeType" : "io1", "Iops" : "100", "AvailabilityZone" : { "Fn::GetAtt" : [ "EC2Instance", "AvailabilityZone" ] } } }

YAML

NewVolume: Type: AWS::EC2::Volume Properties: Size: 100 VolumeType: io1 Iops: 100 AvailabilityZone: !GetAtt Ec2Instance.AvailabilityZone

See Also