问题描述
我想为我的 lambda api 使用自定义域名。我找到了插件 serverless-domain-manager。 我所做的是
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 做了一切)。