Setting the VPC id to blank for unattached igws

This commit is contained in:
Greg Osuri 2014-12-14 14:05:38 -08:00
parent 3883e47902
commit 9b9d147585
1 changed files with 2 additions and 1 deletions

View File

@ -61,7 +61,8 @@ func resourceAwsInternetGatewayRead(d *schema.ResourceData, meta interface{}) er
ig := igRaw.(*ec2.InternetGateway)
if len(ig.Attachments) == 0 {
d.SetId("")
// Gateway exists but not attached to the VPC
d.Set("vpc_id", "")
} else {
d.Set("vpc_id", ig.Attachments[0].VpcId)
}