From 6d927a40db1f46dd7d840d884af9ce8d7ec14931 Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Mon, 1 Aug 2016 10:43:38 +0900 Subject: [PATCH] Fix state detection for the VPN Gateway. Related to https://github.com/hashicorp/terraform/issues/7859. Signed-off-by: Krzysztof Wilczynski --- builtin/providers/aws/resource_aws_vpn_gateway.go | 2 +- .../providers/aws/resource_aws_vpn_gateway_attachment.go | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/builtin/providers/aws/resource_aws_vpn_gateway.go b/builtin/providers/aws/resource_aws_vpn_gateway.go index 2999f005fae4..6a6f1393df44 100644 --- a/builtin/providers/aws/resource_aws_vpn_gateway.go +++ b/builtin/providers/aws/resource_aws_vpn_gateway.go @@ -81,7 +81,7 @@ func resourceAwsVpnGatewayRead(d *schema.ResourceData, meta interface{}) error { } vpnGateway := resp.VpnGateways[0] - if vpnGateway == nil { + if vpnGateway == nil || *vpnGateway.State == "deleted" { // Seems we have lost our VPN gateway d.SetId("") return nil diff --git a/builtin/providers/aws/resource_aws_vpn_gateway_attachment.go b/builtin/providers/aws/resource_aws_vpn_gateway_attachment.go index d1dc47b10fee..0da68f8019dd 100644 --- a/builtin/providers/aws/resource_aws_vpn_gateway_attachment.go +++ b/builtin/providers/aws/resource_aws_vpn_gateway_attachment.go @@ -100,12 +100,7 @@ func resourceAwsVpnGatewayAttachmentRead(d *schema.ResourceData, meta interface{ return nil } - if len(vgw.VpcAttachments) == 0 { - d.Set("vpc_id", "") - return nil - } - - if *vgw.VpcAttachments[0].State == "detached" || *vgw.VpcAttachments[0].State == "deleted" { + if len(vgw.VpcAttachments) == 0 || *vgw.VpcAttachments[0].State == "detached" { d.Set("vpc_id", "") return nil }