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:
app1.example.com -> "" (empty) A record in app1.example.com
new.example.com -> "new" A record in example.com
very.deep.app2.example.com -> "very.deep" A record in example.com
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)
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
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:
app1.example.com
example.com
example.com
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 executesaws 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#L116Requested Resource(s) and/or Data Source(s)
(Mind the trailing 's'!)
Potential Terraform Configuration
References
Get some "inspiration" from similar data source:
AWS API:
Links to comparable data sources:
Would you like to implement a fix?
No