diff --git a/builtin/providers/aws/resource_aws_ebs_volume.go b/builtin/providers/aws/resource_aws_ebs_volume.go index 49d5281a1..1beda135e 100644 --- a/builtin/providers/aws/resource_aws_ebs_volume.go +++ b/builtin/providers/aws/resource_aws_ebs_volume.go @@ -179,7 +179,7 @@ func resourceAWSEbsVolumeUpdate(d *schema.ResourceData, meta interface{}) error stateConf := &resource.StateChangeConf{ Pending: []string{"creating", "modifying"}, - Target: []string{"available"}, + Target: []string{"available", "in-use"}, Refresh: volumeStateRefreshFunc(conn, *result.VolumeModification.VolumeId), Timeout: 5 * time.Minute, Delay: 10 * time.Second, diff --git a/builtin/providers/aws/resource_aws_ebs_volume_test.go b/builtin/providers/aws/resource_aws_ebs_volume_test.go index bb98265a2..1c62247ed 100644 --- a/builtin/providers/aws/resource_aws_ebs_volume_test.go +++ b/builtin/providers/aws/resource_aws_ebs_volume_test.go @@ -30,6 +30,31 @@ func TestAccAWSEBSVolume_basic(t *testing.T) { }) } +func TestAccAWSEBSVolume_updateAttachedEbsVolume(t *testing.T) { + var v ec2.Volume + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "aws_ebs_volume.test", + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccAwsEbsAttachedVolumeConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckVolumeExists("aws_ebs_volume.test", &v), + resource.TestCheckResourceAttr("aws_ebs_volume.test", "size", "10"), + ), + }, + { + Config: testAccAwsEbsAttachedVolumeConfigUpdateSize, + Check: resource.ComposeTestCheckFunc( + testAccCheckVolumeExists("aws_ebs_volume.test", &v), + resource.TestCheckResourceAttr("aws_ebs_volume.test", "size", "20"), + ), + }, + }, + }) +} + func TestAccAWSEBSVolume_updateSize(t *testing.T) { var v ec2.Volume resource.Test(t, resource.TestCase{ @@ -200,6 +225,124 @@ resource "aws_ebs_volume" "test" { } ` +const testAccAwsEbsAttachedVolumeConfig = ` +data "aws_ami" "debian_jessie_latest" { + most_recent = true + + filter { + name = "name" + values = ["debian-jessie-*"] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + filter { + name = "architecture" + values = ["x86_64"] + } + + filter { + name = "root-device-type" + values = ["ebs"] + } + + owners = ["379101102735"] # Debian +} + +resource "aws_instance" "test" { + ami = "${data.aws_ami.debian_jessie_latest.id}" + associate_public_ip_address = true + count = 1 + instance_type = "t2.medium" + + root_block_device { + volume_size = "10" + volume_type = "standard" + delete_on_termination = true + } + + tags { + Name = "test-terraform" + } +} + +resource "aws_ebs_volume" "test" { + depends_on = ["aws_instance.test"] + availability_zone = "${aws_instance.test.availability_zone}" + type = "gp2" + size = "10" +} + +resource "aws_volume_attachment" "test" { + depends_on = ["aws_ebs_volume.test"] + device_name = "/dev/xvdg" + volume_id = "${aws_ebs_volume.test.id}" + instance_id = "${aws_instance.test.id}" +} +` + +const testAccAwsEbsAttachedVolumeConfigUpdateSize = ` +data "aws_ami" "debian_jessie_latest" { + most_recent = true + + filter { + name = "name" + values = ["debian-jessie-*"] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + filter { + name = "architecture" + values = ["x86_64"] + } + + filter { + name = "root-device-type" + values = ["ebs"] + } + + owners = ["379101102735"] # Debian +} + +resource "aws_instance" "test" { + ami = "${data.aws_ami.debian_jessie_latest.id}" + associate_public_ip_address = true + count = 1 + instance_type = "t2.medium" + + root_block_device { + volume_size = "10" + volume_type = "standard" + delete_on_termination = true + } + + tags { + Name = "test-terraform" + } +} + +resource "aws_ebs_volume" "test" { + depends_on = ["aws_instance.test"] + availability_zone = "${aws_instance.test.availability_zone}" + type = "gp2" + size = "20" +} + +resource "aws_volume_attachment" "test" { + depends_on = ["aws_ebs_volume.test"] + device_name = "/dev/xvdg" + volume_id = "${aws_ebs_volume.test.id}" + instance_id = "${aws_instance.test.id}" +} +` + const testAccAwsEbsVolumeConfigUpdateSize = ` resource "aws_ebs_volume" "test" { availability_zone = "us-west-2a"