CloudFormation因Route53 RecordSet和ApiGatewayV2域而失败

时间:2019-06-24 16:25:21

标签: amazon-web-services amazon-cloudformation aws-api-gateway amazon-route53 serverless

我正在使用Serverless通过AWS创建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::JoinFn::GetAtt的{​​{1}}和DNSName块并使用具体值,那么一切都会按预期进行。我是否缺少某些东西,或者这仅仅是CloudFormation和Route53的错误?

0 个答案:

没有答案