hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.79k stars 9.14k forks source link

[Bug]: aws_route53_zone is sorting name_servers #28430

Open batkuip opened 1 year ago

batkuip commented 1 year ago

Terraform Core Version

1.3.6

AWS Provider Version

4.47

Affected Resource(s)

Expected Behavior

The attribute name_servers order matches order in NS record.

Actual Behavior

It's explicitly sorting the name_servers: https://github.com/hashicorp/terraform-provider-aws/blob/main/internal/service/route53/zone.go#L229

This is problematic with (from my use case)

Relevant Error/Panic Output Snippet

~ resource "aws_route53domains_registered_domain" "this" {
      ~ name_server {
          ~ name     = "ns-1546.awsdns-01.co.uk" -> "ns-1417.awsdns-49.org"
            # (1 unchanged attribute hidden)
        }
      ~ name_server {
          ~ name     = "ns-99.awsdns-12.com" -> "ns-1546.awsdns-01.co.uk"
            # (1 unchanged attribute hidden)
        }
      ~ name_server {
          ~ name     = "ns-1417.awsdns-49.org" -> "ns-585.awsdns-09.net"
            # (1 unchanged attribute hidden)
        }
      ~ name_server {
          ~ name     = "ns-585.awsdns-09.net" -> "ns-99.awsdns-12.com"
            # (1 unchanged attribute hidden)
        }
}
### Terraform Configuration Files

resource "aws_route53_zone" "this" {
  name = "my_existing_domain.com"
}

resource "aws_route53domains_registered_domain" "this" {
  domain_name = aws_route53_zone.this.name

  dynamic "name_server" {
    for_each = toset(aws_route53_zone.this.name_servers)
    content {
      name = name_server.value
    }
  }
}

Steps to Reproduce

terraform import aws_route53_zone.this 1234 terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

It's been raised multiple times and fixed for various use cases. Sorting is still there unfortunately. Why does this list need to be sorted explicitly?

References

https://github.com/hashicorp/terraform-provider-aws/issues/21965 https://github.com/hashicorp/terraform-provider-aws/issues/3447

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue