Home > Blockchain >  List public hosted zones in AWS Route53
List public hosted zones in AWS Route53

Time:11-09

I am looking at the aws route53 list-hosted-zones-by-name cli call for AWS Route53 but am unable to find a way to only get the ones that are Public. Is there a way to get this information using aws cli ?

CodePudding user response:

You would look for "PrivateZone": false.

You can do this using JMESPath:

aws route53 list-hosted-zones-by-name --query 'HostedZones[?Config.PrivateZone==`false`].Id'

Or:

aws route53 list-hosetd-zones-by-name --query 'HostedZones[?!(Config.PrivateZone)].Id'

If you want the output as Text instead of JSON, append --output text.

To force the results to separate lines, change .Id to .[Id]

This question has a great explanation of check for false values: Is there a way to convert a JMESPATH boolean to the opposite value? - Stack Overflow

  • Related