How to fetch the AWS Route53 hosted zone id?

后端 未结 4 1342
爱一瞬间的悲伤
爱一瞬间的悲伤 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:25

    I know this may be old but I was able to grab the ID with Powershell when initially creating the DNS zone by doing the following:

    $route53Script = aws route53 create-hosted-zone --delegation-set-id /delegationset/DELIGATIONID --name domain.com --caller-reference blablabla | ConvertFrom-Json
    $Route53ID = $route53Script.HostedZone.Id.replace("/hostedzone/","")
    

    This gives me the Zone ID that I can then use as a variable to do this:

    aws route53 change-resource-record-sets --hosted-zone-id $Route53ID --change-batch file://C:\default.json
    

    I don't know if it's the best way, but it works! I believe you can do almost the same thing in PHP. It's been awhile since I've written some bigger scripts in PHP though.

提交回复
热议问题