provider/aws: fix aws_route53_zone force_destroy behavior (#12421)

The conditional to ignore the deletion of NS and SOA records can fail to
match if the hostedZoneName already ends with a ".". When that happens,
terraform tries to delete those records which is not supported by AWS
and results in a 400 bad request. This fixes the conditional so that it
will work whether or not hostedZoneName ends with a ".".

fixes #12407
This commit is contained in:
Ryan Eschinger 2017-04-23 05:24:37 -04:00 committed by Radek Simko
parent 8343d5908f
commit e2ee211b7b
2 changed files with 2 additions and 2 deletions

View File

@ -300,7 +300,7 @@ func deleteAllRecordsInHostedZoneId(hostedZoneId, hostedZoneName string, conn *r
changes := make([]*route53.Change, 0)
// 100 items per page returned by default
for _, set := range sets {
if *set.Name == hostedZoneName+"." && (*set.Type == "NS" || *set.Type == "SOA") {
if strings.TrimSuffix(*set.Name, ".") == strings.TrimSuffix(hostedZoneName, ".") && (*set.Type == "NS" || *set.Type == "SOA") {
// Zone NS & SOA records cannot be deleted
continue
}

View File

@ -414,7 +414,7 @@ resource "aws_route53_zone" "main" {
const testAccRoute53ZoneConfig_forceDestroy = `
resource "aws_route53_zone" "destroyable" {
name = "terraform.io"
name = "terraform.io."
force_destroy = true
}
`