【问题标题】:AWS CloudFormation: unable to create Route53 record resource for URL to URL mappingAWS CloudFormation:无法为 URL 到 URL 映射创建 Route53 记录资源
【发布时间】:2020-12-17 19:48:07
【问题描述】:

我正在使用 CloudFormation 将我的应用程序部署到 AWS。我正在创建一个 Route53 记录映射 URL 到 URL。但是当我部署我的模板时它失败了。

这是我在模板中的资源。

WebDNS:
    Type: AWS::Route53::RecordSetGroup
    Properties:
      HostedZoneName: waiyanhein.com.
      Comment: Weighted PRs for frontends.
      RecordSets:
        - Name: waiyanhein.com.
          Type: CNAME
          TTL: '900'
          SetIdentifier: Frontend
          Weight: 5
          ResourceRecords:
            - http://patheindirectorytesting.eba-zxqi6pge.eu-west-1.elasticbeanstalk.com/

当我部署时,出现以下错误。

{
            "StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/patheindirectory/dd7eb5b0-e96c-11ea-bcdf-02e29081c656",
            "EventId": "36f3bc50-e975-11ea-b9b2-0ae6d6014b56",
            "StackName": "patheindirectory",
            "LogicalResourceId": "patheindirectory",
            "PhysicalResourceId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/patheindirectory/dd7eb5b0-e96c-11ea-bcdf-02e29081c656",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2020-08-28T21:27:03.035000+00:00",
            "ResourceStatus": "UPDATE_ROLLBACK_IN_PROGRESS",
            "ResourceStatusReason": "The following resource(s) failed to create: [WebDNS]. "
        },
        {
            "StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/patheindirectory/dd7eb5b0-e96c-11ea-bcdf-02e29081c656",
            "EventId": "WebDNS-CREATE_FAILED-2020-08-28T21:27:02.244Z",
            "StackName": "patheindirectory",
            "LogicalResourceId": "WebDNS",
            "PhysicalResourceId": "",
            "ResourceType": "AWS::Route53::RecordSetGroup",
            "Timestamp": "2020-08-28T21:27:02.244000+00:00",
            "ResourceStatus": "CREATE_FAILED",
            "ResourceStatusReason": "[RRSet of type CNAME with DNS name waiyanhein.com. is not permitted at apex in zone waiyanhein.com.]",
            "ResourceProperties": "{\"Comment\":\"Weighted PRs for frontends.\",\"HostedZoneName\":\"waiyanhein.com.\",\"RecordSets\":[{\"Type\":\"CNAME\",\"ResourceRecords\":[\"http://patheindirectorytesting.eba-zxqi6pge.eu-west-1.
elasticbeanstalk.com/\"],\"SetIdentifier\":\"Frontend\",\"TTL\":\"900\",\"Weight\":\"5\",\"Name\":\"waiyanhein.com.\"}]}"
        },

我的模板有什么问题,我该如何解决?

我试过用这个。

WebDNS:
        Type: AWS::Route53::RecordSetGroup
        Properties:
          HostedZoneName: waiyanhein.com.
          Comment: Weighted PRs for frontends.
          RecordSets:
            - Name: waiyanhein.com.
              Type: A
              AliasTarget:
                  DNSName: patheindirectorytesting.eba-zxqi6pge.eu-west-1.elasticbeanstalk.com
                  EvaluateTargetHealth: true
                  HostedZoneId: Z1LQECGX5PH1X
              SetIdentifier: Frontend
              Weight: 5

这次我遇到了这个错误。

{
            "StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/patheindirectory/bb2b3cd0-e9ef-11ea-9251-06755b8a246a",
            "EventId": "84c9cfb0-e9f1-11ea-9a83-0655dfaca74c",
            "StackName": "patheindirectory",
            "LogicalResourceId": "patheindirectory",
            "PhysicalResourceId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/patheindirectory/bb2b3cd0-e9ef-11ea-9251-06755b8a246a",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2020-08-29T12:16:51.229000+00:00",
            "ResourceStatus": "ROLLBACK_IN_PROGRESS",
            "ResourceStatusReason": "The following resource(s) failed to create: [WebDNS]. . Rollback requested by user."
        },
        {
            "StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/patheindirectory/bb2b3cd0-e9ef-11ea-9251-06755b8a246a",
            "EventId": "WebDNS-CREATE_FAILED-2020-08-29T12:16:50.249Z",
            "StackName": "patheindirectory",
            "LogicalResourceId": "WebDNS",
            "PhysicalResourceId": "",
            "ResourceType": "AWS::Route53::RecordSetGroup",
            "Timestamp": "2020-08-29T12:16:50.249000+00:00",
            "ResourceStatus": "CREATE_FAILED",
            "ResourceStatusReason": "[Tried to create an alias that targets patheindirectorytesting.eba-zxqi6pge.eu-west-1.elasticbeanstalk.com., type A in zone Z1LQECGX5PH1X, but the alias target name does not lie within the target
 zone, RRSet with DNS name waiyanhein.com., type A, SetIdentifier Frontend cannot be created as a non-weighted set exists with the same name and type.]",
            "ResourceProperties": "{\"Comment\":\"Weighted PRs for frontends.\",\"HostedZoneName\":\"waiyanhein.com.\",\"RecordSets\":[{\"AliasTarget\":{\"HostedZoneId\":\"Z1LQECGX5PH1X\",\"DNSName\":\"patheindirectorytesting.eba-zx
qi6pge.eu-west-1.elasticbeanstalk.com\",\"EvaluateTargetHealth\":\"true\"},\"Type\":\"A\",\"SetIdentifier\":\"Frontend\",\"Weight\":\"5\",\"Name\":\"waiyanhein.com.\"}]}"
        },

【问题讨论】:

  • dns 记录与 URL 不同。您正在尝试将 CNAME 的值设置为 URL 而不是 dns 名称。
  • 我需要用什么来获得我想要达到的目标?
  • 您需要创建一个指向patheindirectorytesting.eba-zxqi6pge.eu-west-1.elasticbeanstalk.com 的别名记录(不是CNAME)。您不能对顶级域进行 CNAME。

标签: amazon-web-services amazon-cloudformation amazon-route53


【解决方案1】:

由于您的 EB 域中包含区域名称 (eu-west-1),我认为最好的方法是为其设置别名记录:

为此,您需要获取您所在地区的 HostedZoneId,即Z1LQECGX5PH1X,如列出的here。

随后,您的 RecordSet 可能是:

    WebDNS:
        Type: AWS::Route53::RecordSetGroup
        Properties:
          HostedZoneName: waiyanhein.com.
          Comment: Weighted PRs for frontends.
          RecordSets:
            - Name: waiyanhein.com.
              Type: A
              AliasTarget:
                  DNSName: patheindirectorytesting.eba-zxqi6pge.eu-west-1.elasticbeanstalk.com
                  EvaluateTargetHealth: true
                  HostedZoneId: Z1LQECGX5PH1X
              SetIdentifier: Frontend
              Weight: 5

【讨论】:

  • 嗨,@Macin。我试过用这个。我仍然收到错误消息。我已更新问题以包含错误。皮斯,看看。
  • @WaiYanHein 嗨。新错误表明您已有 waiyanhein.com。记录哪个不是重量。所以显然你不能有重复。因此,您必须检查为什么您有第二条记录?它是在控制台中手动创建的还是在模板的其他未显示部分中创建的?
  • @WaiYanHein 你有没有弄清楚为什么会有重复记录?
  • 我尝试删除具有该域名的现有 A 记录。我又部署了。它仍然抛出错误。
  • @WaiYanHein 你确定你必须创建Name: waiyanhein.com.吗?也许它必须是不同的域,例如,Name: app.waiyanhein.com. 或 Name: api.waiyanhein.com.?
猜你喜欢
  • 1970-01-01
  • 2020-12-12
  • 2022-11-16
  • 1970-01-01
  • 2019-08-31
  • 2023-03-24
  • 2020-11-15
  • 2022-11-28
  • 1970-01-01
相关资源
最近更新 更多