How to fetch the AWS Route53 hosted zone id?

后端 未结 4 1378
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-13 11:46

I am newbie to Amazon Services and their API.

Using Amazon route53Clinet class, I know there is a method getHostedZone which get the Hosted Zone information on the

4条回答
  •  青春惊慌失措
    2021-01-13 12:27

    I use the AWS CLI and pipe the JSON results to the jq tool:

    aws route53 list-hosted-zones-by-name | 
    jq --arg name "example.com." \
    -r '.HostedZones | .[] | select(.Name=="\($name)") | .Id'
    

    The jq expression selects each hosted zone JSON item that contains the name "example.com". Heads up that this may return more than one record.

    The output is the matching hosted zone id strings such as:

    /hostedzone/ABCDEF12345678
    

    You can then list resource record sets for a hosted zone id:

    aws route53 list-resource-record-sets \
    --hosted-zone-id "/hostedzone/ABCDEF12345678"
    

提交回复
热议问题