From e33739209b01c6a8771cbea0fa41e11d825b7fe5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 7 Jul 2014 17:07:31 -0700 Subject: [PATCH] providers/aws: its okay to delete something that is already gone --- builtin/providers/aws/resource_aws_internet_gateway.go | 5 +++++ builtin/providers/aws/resource_aws_subnet.go | 5 +++++ builtin/providers/aws/resource_aws_vpc.go | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/builtin/providers/aws/resource_aws_internet_gateway.go b/builtin/providers/aws/resource_aws_internet_gateway.go index c45f99d4f..d7542aab6 100644 --- a/builtin/providers/aws/resource_aws_internet_gateway.go +++ b/builtin/providers/aws/resource_aws_internet_gateway.go @@ -56,6 +56,11 @@ func resource_aws_internet_gateway_destroy( log.Printf("[INFO] Deleting Internet Gateway: %s", s.ID) if _, err := ec2conn.DeleteInternetGateway(s.ID); err != nil { + ec2err, ok := err.(*ec2.Error) + if ok && ec2err.Code == "InvalidInternetGatewayID.NotFound" { + return nil + } + return fmt.Errorf("Error deleting internet gateway: %s", err) } diff --git a/builtin/providers/aws/resource_aws_subnet.go b/builtin/providers/aws/resource_aws_subnet.go index 44180d143..4e0ef5597 100644 --- a/builtin/providers/aws/resource_aws_subnet.go +++ b/builtin/providers/aws/resource_aws_subnet.go @@ -78,6 +78,11 @@ func resource_aws_subnet_destroy( log.Printf("[INFO] Deleting Subnet: %s", s.ID) if _, err := ec2conn.DeleteSubnet(s.ID); err != nil { + ec2err, ok := err.(*ec2.Error) + if ok && ec2err.Code == "InvalidSubnetID.NotFound" { + return nil + } + return fmt.Errorf("Error deleting subnet: %s", err) } diff --git a/builtin/providers/aws/resource_aws_vpc.go b/builtin/providers/aws/resource_aws_vpc.go index 3f8646015..218b3bc17 100644 --- a/builtin/providers/aws/resource_aws_vpc.go +++ b/builtin/providers/aws/resource_aws_vpc.go @@ -76,6 +76,11 @@ func resource_aws_vpc_destroy( log.Printf("[INFO] Deleting VPC: %s", s.ID) if _, err := ec2conn.DeleteVpc(s.ID); err != nil { + ec2err, ok := err.(*ec2.Error) + if ok && ec2err.Code == "InvalidVpcID.NotFound" { + return nil + } + return fmt.Errorf("Error deleting ELB: %s", err) }