From ca99811357c6fdf9f44b7fe0eec6ebdb12499cd6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 7 Oct 2014 21:52:08 -0700 Subject: [PATCH] providers/aws: subnet retry destroy [GH-357] --- CHANGELOG.md | 2 ++ builtin/providers/aws/resource_aws_subnet.go | 6 +++++- builtin/providers/aws/resource_provider_test.go | 3 --- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e04249164..6a5f4c860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,8 @@ BUG FIXES: * core: Plugin loading from CWD works properly. * providers/aws: autoscaling_group can be launched into a vpc [GH-259] * providers/aws: not an error when RDS instance is deleted manually. [GH-307] + * providers/aws: Retry deleting subnet for some time while AWS eventually + destroys dependencies. [GH-357] ## 0.2.2 (September 9, 2014) diff --git a/builtin/providers/aws/resource_aws_subnet.go b/builtin/providers/aws/resource_aws_subnet.go index 650b13363..53d54e3df 100644 --- a/builtin/providers/aws/resource_aws_subnet.go +++ b/builtin/providers/aws/resource_aws_subnet.go @@ -88,7 +88,11 @@ func resource_aws_subnet_destroy( ec2conn := p.ec2conn log.Printf("[INFO] Deleting Subnet: %s", s.ID) - if _, err := ec2conn.DeleteSubnet(s.ID); err != nil { + f := func() error { + _, err := ec2conn.DeleteSubnet(s.ID) + return err + } + if err := resource.Retry(10 * time.Second, f); err != nil { ec2err, ok := err.(*ec2.Error) if ok && ec2err.Code == "InvalidSubnetID.NotFound" { return nil diff --git a/builtin/providers/aws/resource_provider_test.go b/builtin/providers/aws/resource_provider_test.go index 18df993c2..b376f62b8 100644 --- a/builtin/providers/aws/resource_provider_test.go +++ b/builtin/providers/aws/resource_provider_test.go @@ -92,7 +92,4 @@ func testAccPreCheck(t *testing.T) { log.Println("[INFO] Test: Using us-west-2 as test region") os.Setenv("AWS_REGION", "us-west-2") } - if v := os.Getenv("AWS_SSL_CERTIFICATE_ID"); v == "" { - t.Fatal("AWS_SSL_CERTIFICATE_ID must be set for acceptance tests") - } }