AWS Amazon EC2 Volume

This page shows how to write Terraform and CloudFormation for Amazon EC2 Volume and write them securely.

code-icon

Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.

get-started-button

Terraform Example (aws_ebs_volume)

Manages a single EBS volume.

Parameters

Example Usage (from GitHub)

github-iconGuyBarros/terraform-hcp-demostack-aws
resource "aws_ebs_volume" "mysql" {
  availability_zone = data.aws_availability_zones.available.names[0]
  size              = 40
}

resource "aws_ebs_volume" "mongodb" {
github-icondilfuza97/Kops_cluster_Terraform
resource "aws_ebs_volume" "a-etcd-events-dilfuzacluster-com" {
  availability_zone = "eu-west-1a"
  size              = 20
  type              = "gp2"
  encrypted         = false

github-iconcsamatov96/K8_cluster_kops
resource "aws_ebs_volume" "a-etcd-events-csamatov-net" {
  availability_zone = "eu-west-1a"
  size              = 20
  type              = "gp2"
  encrypted         = false

CloudFormation Example (AWS::EC2::Volume)

Specifies an Amazon Elastic Block Store (Amazon EBS) volume. You can attach the volume to an instance in the same Availability Zone using AWS::EC2::VolumeAttachment.

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 sizing down an Amazon EBS volume. AWS CloudFormation does 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 when modifying volumes.

DeletionPolicy attributeTo 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.

Parameters

Frequently asked questions

What is AWS Amazon EC2 Volume?

AWS Amazon EC2 Volume is a resource for Amazon EC2 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Amazon EC2 Volume?

For Terraform, the GuyBarros/terraform-hcp-demostack-aws, dilfuza97/Kops_cluster_Terraform and csamatov96/K8_cluster_kops source code examples are useful. See the Terraform Example section for further details.