From f3deaab87861b9af9d84aba374f81a84bc7a934c Mon Sep 17 00:00:00 2001 From: Jonathan McCall Date: Thu, 29 Sep 2016 17:56:52 -0400 Subject: [PATCH] Remove resource if volume to detach is missing --- builtin/providers/aws/resource_aws_volume_attachment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_volume_attachment.go b/builtin/providers/aws/resource_aws_volume_attachment.go index 801f06190..e858a974f 100644 --- a/builtin/providers/aws/resource_aws_volume_attachment.go +++ b/builtin/providers/aws/resource_aws_volume_attachment.go @@ -162,7 +162,7 @@ func resourceAwsVolumeAttachmentDelete(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error reading EC2 volume %s: %s", vID, desc_err) } - if *attr.Volumes[0].State == "available" { + if len(attr.Volumes) == 0 || *attr.Volumes[0].State == "available" { d.SetId("") return nil }