AWS CLI - route53 change-resource-record-sets 命令在 A 记录时失败但在 CNAME 时通过

AWS CLI - route53 change-resource-record-sets command failing if A record but passes if CNAME

我正在尝试在现有托管区域中添加 DNS 记录。我正在尝试使用 ResourceRecordSet 类型作为 A 记录和 CNAME 记录的以下命令。尝试创建 A 记录的命令失败,但更改为 CNAME 时相同的命令有效

命令失败

aws route53 change-resource-record-sets --hosted-zone-id XXXXXXXXXXXXX --change-batch {"Changes": [{"Action": "CREATE","ResourceRecordSet": {"Name": "api-test-1.envio.systems","Type": "A","TTL": 30,"ResourceRecords": [{"Value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-14xxxxxxxxxxxxx26.elb.eu-central-1.amazonaws.com"}]}}]}

错误:

An error occurred (InvalidChangeBatch) when calling the ChangeResourceRecordSets operation: [Invalid Resource Record: FATAL problem: ARRDATAIllegalIPv4Address (Value is not a valid IPv4 address) encountered with 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-14xxxxxxxxxxxxx26.elb.eu-central-1.amazonaws.com.']

下面的命令有效,唯一改变的是 ResourceRecordSet 类型从 A 到 CNAME

aws route53 change-resource-record-sets --hosted-zone-id XXXXXXXXXXXXX --change-batch {"Changes": [{"Action": "CREATE","ResourceRecordSet": {"Name": "api-test-st-1.envio.systems","Type": "CNAME","TTL": 30,"ResourceRecords": [{"Value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-14xxxxxxxxxxxxx26.elb.eu-central-1.amazonaws.com"}]}}]}

问题是什么?为什么 CNAME 使用相同的命令而不是 A 记录?

在 DNS 中,A(“地址”)记录指向 IPv4 地址CNAME 记录指向另一个 dns 名称.

AWS 确实有记录 aliases 的概念,它本质上是一个 CNAME 记录,它对值进行内部 Route 53 查找并作为 A 记录出现。

https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-elb-load-balancer.html describes how to set up an Alias record. https://aws.amazon.com/premiumsupport/knowledge-center/alias-resource-record-set-route53-cli/ 谈到用 CLI 来做,它更准确地表示 API 接受的字段。基本上,您指定 ELB 的 DNS 记录的托管区域 ID 及其地址。

https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-choosing-alias-non-alias.html