From 5bec1ac3830bf1c0ed91e94882d2287aaf15764d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 8 Jul 2014 16:02:01 -0700 Subject: [PATCH] providers/aws: gateway detach is idempotent --- builtin/providers/aws/resource_aws_internet_gateway.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_internet_gateway.go b/builtin/providers/aws/resource_aws_internet_gateway.go index e26c81da2..276a3577f 100644 --- a/builtin/providers/aws/resource_aws_internet_gateway.go +++ b/builtin/providers/aws/resource_aws_internet_gateway.go @@ -181,7 +181,14 @@ func resource_aws_internet_gateway_detach( s.Attributes["vpc_id"]) _, err := ec2conn.DetachInternetGateway(s.ID, s.Attributes["vpc_id"]) if err != nil { - return err + ec2err, ok := err.(*ec2.Error) + if ok && ec2err.Code == "Gateway.NotAttached" { + err = nil + } + + if err != nil { + return err + } } delete(s.Attributes, "vpc_id")