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. Use DescribeAvailabilityZones to list the Availability Zones that are currently available to you.

Required: Yes

Type: String

Update requires: No interruption

Encrypted

Specifies the encryption state of the volume. The default effect of setting this parameter depends on the volume's source and ownership. Each default case can be overridden by specifying a customer master key (CMK) with the KeyKeyId parameter. For a complete list of possible encryption cases, see Amazon EBS Encryption.

Encrypted Amazon EBS volumes may only 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

An identifier for the AWS Key Management Service (AWS KMS) customer master key (CMK) to use when creating the encrypted volume. This parameter is only required if you want to use a non-default CMK; if this parameter is not specified, the default CMK for EBS is used. If a KmsKeyId is specified, the Encrypted flag must also be set.

The CMK identifier may be provided in any of the following formats:

  • Key ID

  • Key alias. The alias ARN contains the arn:aws:kms namespace, followed by the Region of the CMK, the AWS account ID of the CMK owner, the alias namespace, and then the CMK alias. For example, arn:aws:kms:us-east-1:012345678910:alias/ExampleAlias.

  • ARN using key ID. The ID ARN contains the arn:aws:kms namespace, followed by the Region of the CMK, the AWS account ID of the CMK owner, the key namespace, and then the CMK ID. For example, arn:aws:kms:us-east-1:012345678910:key/abcd1234-a123-456a-a12b-a123b4cd56ef.

  • ARN using key alias. The alias ARN contains the arn:aws:kms namespace, followed by the Region of the CMK, the AWS account ID of the CMK owner, the alias namespace, and then the CMK alias. For example, arn:aws:kms:us-east-1:012345678910:alias/ExampleAlias.

AWS parses KmsKeyId asynchronously, meaning that the action you call may appear to complete even though you provided an invalid identifier. The action will eventually fail.

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 are 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" }

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" ] } } }

See Also