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.63k stars 9.01k forks source link

[New Data Source]: `aws_route53_zones` Get list (!) of hosted zones #37465

Open DJAlPee opened 2 months ago

DJAlPee commented 2 months ago

Description

I have several hosted zones in my AWS account and some zones are sub-zones e.g. example.com, app1.example.com, app2.example.com, etc., which are managed by an "external" stack.

If I want to to place a new application to my account, I want to select the "best fitting" zone, depending on the domain for the new application:

I have already implented a some logic with terraform functions for selecting the zone, but for getting the list of hosted zones I'm using external provider, which just executes aws route53 list-hosted-zones --query HostedZones --output json (plus some hacky workaround by converting this output to base64, because this data source supports "key/value JSON", only)

It would be great, if I could use a native list data source for better stability and less external dependencies... This new data source might be ideal for new contributers, because of existing similar list data sources and the "List" API is already being used by the existing aws_route53_zone(without trailing 's'): https://github.com/hashicorp/terraform-provider-aws/blob/42ad9820ef6474603f0910bded17b1679704375c/internal/service/route53/zone_data_source.go#L116

Requested Resource(s) and/or Data Source(s)

(Mind the trailing 's'!)

Potential Terraform Configuration

data "aws_route53_zones" "account_zones" {
  private_zone = false
}

References

Get some "inspiration" from similar data source:

AWS API:

Links to comparable data sources:

Would you like to implement a fix?

No

github-actions[bot] commented 2 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

ilBarlo commented 1 month ago

It will be very helpful

a-ricciuto commented 1 month ago

I agree, I need this feature