Amazon web services AWS CloudFormation:无法为URL到URL映射创建Route53记录资源

Amazon web services AWS CloudFormation:无法为URL到URL映射创建Route53记录资源,amazon-web-services,amazon-cloudformation,amazon-route53,Amazon Web Services,Amazon Cloudformation,Amazon Route53,我正在使用CloudFormation将我的应用程序部署到AWS。我正在创建一个Route53记录,将URL映射到URL。但当我部署模板时,它失败了 WebDNS: Type: AWS::Route53::RecordSetGroup Properties: HostedZoneName: waiyanhein.com. Comment: Weighted PRs for frontends. RecordSets: - Nam

我正在使用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/
这是我在模板中的资源

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.\"}]}"
        },

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

要做到这一点,您需要获取您所在地区的HostedZoneId,它将是所列的
z1qecgx5ph1x

随后,您的记录集可能是:

    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

dns记录与URL不同。您正在尝试将CNAME的值设置为URL而不是dns名称。我需要使用什么来获得我想要的结果?您需要创建一个别名记录(而不是CNAME),指向
路径indirectoryTesting.eba-zxqi6pge.eu-west-1.elasticbeanstalk.com
。您不能为顶级域名命名。您好,@Macin。我试过用这个。我仍然得到错误。我已经更新了问题以包含错误。皮斯,看一看。@WaiYanHein嗨。新的错误表明您已经拥有waiyanhein.com。记录不是重量的东西。所以很明显,你不能有重复。因此,您必须检查为什么有第二个记录?它是在控制台中手动创建的,还是在模板的其他未显示部分中创建的?@WaiYanHein您是否已设法找出重复记录的原因?我尝试删除具有该域名的现有记录。我再次部署。它仍在抛出错误。@WaiYanHein您确定必须创建
名称:WaiYanHein.com.
?可能它必须是不同的域,例如,
名称:app.waiyanhein.com。
名称:api.waiyanhein.com。