Merge pull request #9023 from Jonnymcc/destroying-detached-vol-attch-res
provider/aws: Skip DetachVolume if volume is not attached
This commit is contained in:
commit
f1c5f848e9
|
@ -136,7 +136,7 @@ func resourceAwsVolumeAttachmentRead(d *schema.ResourceData, meta interface{}) e
|
|||
},
|
||||
}
|
||||
|
||||
_, err := conn.DescribeVolumes(request)
|
||||
vols, err := conn.DescribeVolumes(request)
|
||||
if err != nil {
|
||||
if ec2err, ok := err.(awserr.Error); ok && ec2err.Code() == "InvalidVolume.NotFound" {
|
||||
d.SetId("")
|
||||
|
@ -144,6 +144,11 @@ func resourceAwsVolumeAttachmentRead(d *schema.ResourceData, meta interface{}) e
|
|||
}
|
||||
return fmt.Errorf("Error reading EC2 volume %s for instance: %s: %#v", d.Get("volume_id").(string), d.Get("instance_id").(string), err)
|
||||
}
|
||||
|
||||
if len(vols.Volumes) == 0 || *vols.Volumes[0].State == "available" {
|
||||
d.SetId("")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue