首页 > 解决方案 > CloudFormation 因 Route53 RecordSet 和 ApiGatewayV2 域而失败

问题描述

我正在使用ServerlessAWS 创建一个 WebSocket API。我在serverless.yml文件中添加了以下额外的 CloudFormation 资源:

Resources:
  ApiGatewayDomain:
    Type: AWS::ApiGatewayV2::DomainName
    Properties: 
      DomainName: ${opt:id}.example.com
      DomainNameConfigurations: 
        - EndpointType: REGIONAL
          CertificateArn: arn:aws:acm:eu-central-1:<REDACTED>:certificate/<REDACTED>

  ApiGatewayBasePathMapping:
    Type: AWS::ApiGatewayV2::ApiMapping
    Properties:
      DomainName: # ${opt:id}.example.com
        Ref: ApiGatewayDomain
      ApiId:
        Ref: "WebsocketsApi"
      Stage: ${opt:stage, 'dev'}
    DependsOn:
      - WebsocketsDeployment${sls:instanceId}
      - WebsocketsDeploymentStage

  Route53RecordSet:
    Type: AWS::Route53::RecordSet
    Properties:
      Type: A
      HostedZoneId: <REDACTED>
      Name:
        Ref: ApiGatewayDomain
      AliasTarget:
        DNSName: # <REDACTED>.execute-api.eu-central-1.amazonaws.com.
          Fn::Join:
            - ""
            -
              - Fn::GetAtt: [ApiGatewayDomain, RegionalDomainName]
              - "."
        HostedZoneId: # Z1U9ULNL0V5AJ3
          Fn::GetAtt: [ApiGatewayDomain, RegionalHostedZoneId]
    DependsOn:
      - ApiGatewayDomain

我想实现,堆栈的部署注册一个自定义 api 网关域(有效),设置路径映射(有效)并添加一个 Route53RecordSet(仅适用于具体值)。

我无法弄清楚我做错了什么并且总是从 Route53 收到内部错误。如果我注释掉Fn::JoinandFn::GetAttDNSNameHostedZoneId使用具体值,一切都会按预期工作。我是否遗漏了什么,或者这仅仅是 CloudFormation 和 Route53 的错误?

标签: amazon-web-servicesamazon-cloudformationaws-api-gatewayamazon-route53serverless

解决方案


推荐阅读