无服务器域管理器错误:无法获取有关 uat-api.mydomain.com 的信息

问题描述

我想为我的 lambda api 使用自定义域名。我找到了插件 serverless-domain-manager。 我所做的是

  1. 安装插件
  2. 在 aws/api 网关中创建自定义域名:uat-api.mydomain.com
  3. 创建一个指向我的自定义域名的 dns 记录
  4. 自定义配置添加到 serverless.yml 文件
 custom:
        customDomain:
        domainName: uat-api.mydomain.com
        basePath: api
        certificateName: som-cert-name.com
        certificateArn: arnid
        createRoute53Record: true
        endpointType: ‘regional’
        securityPolicy: tls_1_2
        apiType: rest
        autodomain: false
        hostedZoneId: Z1I1XQT4F25333

不,当我运行 sls create_domain 时出现错误

[AWS apigatewayv2 403 3.044s 0 retries] getDomainName({ DomainName: ‘uat-api.mydomain.com’ })

  Error --------------------------------------------------
 
  Error: Unable to fetch information about uat-api.mydomain.com
      at APIGatewayWrapper.<anonymous> (/Users/../node_modules/serverless-domain-manager/dist/src/aws/api-gateway-wrapper.js:112:27)
      at Generator.throw (<anonymous>)
      at rejected (/../node_modules/serverless-domain-manager/dist/src/aws/api-gateway-wrapper.js:6:65)
      at process._tickCallback (internal/process/next_tick.js:68:7)

所以,怎么了,我错过了什么?

解决方法

我知道这是 npm/github 自述文件中提供的配置,但坦率地说,这似乎有点矫枉过正。

plugins:
  - serverless-domain-manager
custom:
  customDomain:
    domainName: 'test.****.io'
    basePath: 'somePath'
    stage: ${self:provider.stage}
    createRoute53Record: true

这是我使用的配置 - 该域托管在 Route53 中,但除此之外,当我创建一个新的子域时,我根本不需要弄乱 AWS 控制台(在这种情况下,create_domain 做了一切)。