我在 Route53 中有一个区域,我需要其采用 BIND 兼容格式。
我该如何转换它?
答案1
@MikeyB 你的回答很棒。有时 aws cli 上的默认输出不是 json,因此你需要添加 --output json 才能成功执行。
aws route53 list-resource-record-sets --hosted-zone-id «zoneid» --output json | \
jq -r '.ResourceRecordSets[] | "\(.Name) \(.TTL) IN \(.Type) \(.ResourceRecords[] | join("\n"))"'
答案2
aws route53 list-resource-record-sets --hosted-zone-id «zoneid» | \
jq -r '.ResourceRecordSets[] | "\(.Name) \(.TTL) IN \(.Type) \(.ResourceRecords[] | join("\n"))"'
示例输出:
contoso.com. 300 IN A 192.0.2.42
contoso.com. 300 IN A 198.51.100.0.42
contoso.com. 300 IN AAAA 2001:db8:1234::
contoso.com. 300 IN AAAA 2001:db8:5678::
contoso.com. 172800 IN NS ns-1273.awsdns-31.org.
contoso.com. 172800 IN NS ns-729.awsdns-27.net.
contoso.com. 172800 IN NS ns-367.awsdns-45.com.
contoso.com. 172800 IN NS ns-1816.awsdns-35.co.uk.
contoso.com. 900 IN SOA ns-1273.awsdns-31.org. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400
www.contoso.com. 300 IN A 192.0.2.42
www.contoso.com. 300 IN A 198.51.100.0.42
www.contoso.com. 300 IN AAAA 2001:db8:1234::
www.contoso.com. 300 IN AAAA 2001:db8:5678::