AWS CloudFormation:无法创建用于URL到URL映射的Route53记录资源

时间:2020-08-28 21:40:55

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

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

这是我在模板中的资源。

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

1 个答案:

答案 0 :(得分:0)

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

为此,您需要获取您所在区域的HostedZoneId,其名称为here,为Z1LQECGX5PH1X

随后,您的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