我正在尝试使用自定义域来部署基本的无服务器快速api示例- https://github.com/serverless/examples/tree/v2/aws-node-express-api。它使用HTTP Api而不是旧的REST网关。域已成功设置,证书已到位等,但当我运行serverless deploy时,它会引发一个错误:
Error: Unable to setup base domain mappings for mycustom.domain.name添加SLS_DEBUG显示:
Service Information
-------------------
service: my-service-name
stage: staging
region: us-east-1
stack: my-service-name-staging
resources: 11
api keys:
None
endpoints:
ANY - https://123323.execute-api.us-east-1.amazonaws.com
functions:
api: my-service-name-staging-api
layers:
None
Serverless: [AWS cloudformation 400 1.296s 0 retries] describeStackResource({
LogicalResourceId: 'ApiGatewayRestApi',
StackName: 'my-service-name-staging'
})
Serverless: [AWS cloudformation 200 1.592s 0 retries] describeStacks({})
Serverless Domain Manager: Error: mycustom.domain.name: Error: Failed to find a stack my-service-name-staging
Serverless Domain Manager: Error: mycustom.domain.name: Error: Failed to find CloudFormation resources for mycustom.domain.name显然堆栈存在,但无服务器域管理器无法找到它。我能不能通过HTTP通过无服务器域管理器使用自定义域??文档中只显示了一个手动方式来完成这个任务。任何帮助都将不胜感激,谢谢!
发布于 2022-01-22 16:16:48
很难在没有看到您的配置的情况下100%地回答,但是您确定您已经在apiType: http配置部分指定了customDomain吗?如果没有,则默认为rest。将其设置为http可以解决您的问题。
发布于 2022-10-21 17:50:54
由于您的完整serverless.yml不在这里,我想您使用的是默认的。我也有同样的问题,这是我的解决方案。这可能是您的customDomain文件中的.yml conf:
customDomain:
domainName: sub.domain.com
certificateName: '*.domain.com'
basePath: ${sls:stage}
stage: ${sls:stage}
createRoute53Record: true唯一需要做的就是添加这两个属性来将域从边缘转换为区域:
customDomain:
domainName: sub.domain.com
certificateName: '*.domain.com'
basePath: ${sls:stage}
stage: ${sls:stage}
createRoute53Record: true
endpointType: regional <-- New Attribute (default is edge)
apiType: http <-- New Attribute (default is rest)请记住,如果您已经运行了sls create_domain命令(使用前面的serverless.yml配置),您可能会遇到以下错误:
Error:
Error: Unable to setup base domain mappings for 'sub.domain.com':
Unable to create base path mapping for 'sub.domain.com':
Only REGIONAL domain names can be managed through the API Gateway V2 API. For EDGE domain names, please use the API Gateway V1 API. Also note that only REST APIs can be attached to EDGE domain names.造成此错误的原因是您已经使用前面的配置创建了边缘域,现在部署希望将其用作区域域。要解决此错误,只需使用sls delete_domain删除域,然后重新运行sls create_domain命令。我会自动为你创建新的记录。
https://stackoverflow.com/questions/70804311
复制相似问题