|
|
|
|
@ -153,6 +153,20 @@ func resourceAwsVolumeAttachmentDelete(d *schema.ResourceData, meta interface{})
|
|
|
|
|
vID := d.Get("volume_id").(string)
|
|
|
|
|
iID := d.Get("instance_id").(string)
|
|
|
|
|
|
|
|
|
|
desc_opts := &ec2.DescribeVolumesInput{
|
|
|
|
|
VolumeIds: []*string{aws.String(vID)},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
attr, desc_err := conn.DescribeVolumes(desc_opts)
|
|
|
|
|
if desc_err != nil {
|
|
|
|
|
return fmt.Errorf("Error reading EC2 volume %s: %s", vID, desc_err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if *attr.Volumes[0].State == "available" {
|
|
|
|
|
d.SetId("")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
opts := &ec2.DetachVolumeInput{
|
|
|
|
|
Device: aws.String(d.Get("device_name").(string)),
|
|
|
|
|
InstanceId: aws.String(iID),
|
|
|
|
|
|