From 3a3e3346d5855db591223e8e7c2cf80e13bd351d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 31 Aug 2014 09:12:05 -0700 Subject: [PATCH] providers/aws: route53 record destroy in parallel works --- CHANGELOG.md | 1 + .../aws/resource_aws_route53_record.go | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 935fd2c99..eea57dd58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ BUG FIXES: * core: Depending on a computed variable of a list type generates a plan without failure. i.e. `${type.name.foos.0.bar}` where `foos` is computed. [GH-247] + * providers/aws: Route53 destroys in parallel work properly. [GH-183] ## 0.2.0 (August 28, 2014) diff --git a/builtin/providers/aws/resource_aws_route53_record.go b/builtin/providers/aws/resource_aws_route53_record.go index dcd8324ce..e385090b0 100644 --- a/builtin/providers/aws/resource_aws_route53_record.go +++ b/builtin/providers/aws/resource_aws_route53_record.go @@ -157,10 +157,30 @@ func resource_aws_r53_record_destroy( zone := s.Attributes["zone_id"] log.Printf("[DEBUG] Deleting resource records for zone: %s, name: %s", zone, s.Attributes["name"]) - _, err = conn.ChangeResourceRecordSets(zone, req) - if err != nil { + wait := resource.StateChangeConf{ + Pending: []string{"rejected"}, + Target: "accepted", + Timeout: 5 * time.Minute, + MinTimeout: 1 * time.Second, + Refresh: func() (interface{}, string, error) { + _, err := conn.ChangeResourceRecordSets(zone, req) + if err != nil { + if strings.Contains(err.Error(), "PriorRequestNotComplete") { + // There is some pending operation, so just retry + // in a bit. + return nil, "rejected", nil + } + + return nil, "failure", err + } + + return nil, "accepted", nil + }, + } + if _, err := wait.WaitForState(); err != nil { return err } + return nil }