使用aws change-resource-record-sets添加别名时出错

时间:2013-11-12 16:58:27

标签: amazon-web-services amazon-route53

我正在尝试使用aws change-resource-record-sets来添加别名。我们的想法是允许通过我们域上的URL访问Cloudfront分发版(例如mydomainname.mycompany.co.uk而不是mydomainname.cloudfront.net,其中mydomainname =类似 d4dzc6m38sq0mk

在解决了我解决的各种其他JSON错误后,我仍然遇到问题。

A client error (InvalidChangeBatch) occurred: RRSet with DNS name 
mydomainname.cloudfront.net. is not permitted in zone mycompany.co.uk.

我有什么问题?

JSON:

{
  "Comment": "Recordset for mydomainname",
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "mydomainname",
        "Type": "A",
        "AliasTarget": {
          "HostedZoneId": "Z2FDTNDATAQYW2",
          "DNSName": "mydomainname.cloudfront.net.",
          "EvaluateTargetHealth": false
        }
      }
    }
  ]
}

已编辑以澄清HostedZoneID。

3 个答案:

答案 0 :(得分:4)

您需要在NAME参数中传递完整名称。对于你的例子,你需要传递这个:

"Name" : "mydomainname.cloudfront.net."

答案 1 :(得分:2)

如果“我们的想法是允许通过我们域上的网址访问Cloudfront分发版...”,请尝试使用CNAME而不是别名......

aws route53 change-resource-record-sets --hosted-zone-id Z3A********TC8 --change-batch file://~/tmp/awsroute53recordset.json

awsroute53recordset.json

{
  "Comment": "Allow access to a Cloudfront distribution via URL on our domain",
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "cdn.mycompany.co.uk",
        "Type": "CNAME",
        "TTL": 3600,
        "ResourceRecords": [
          {
            "Value": "d4dzc6m38sq0mk.cloudfront.net"
          }
        ]
      }
    }
  ]
}

答案 2 :(得分:0)

您必须添加'更改' =>节点

            'Comment' => 'Created Programmatically',
            'Changes' => [
                'Change'=>[
                    'Action' => 'CREATE',
                    'ResourceRecordSet' => [
                        'Name' => $domainName.'.',
                        'Type' => 'A',
                        'AliasTarget' => [
                            'HostedZoneId' => '*ZoneID*',
                            'DNSName' => '*DNSName*',
                            'EvaluateTargetHealth' => false
                        ]
                    ]
                ],