【发布时间】:2021-06-17 03:56:31
【问题描述】:
以下是我做的步骤
- 使用区域选项创建了一个自定义域,并在路线 53 中创建了“A”记录
- 手动/通过无服务器配置我的 API 映射并进行测试。效果很好。
- 现在我尝试设置一个 VPC 端点并在我的无服务器中进行相同的配置。但是这次在部署时出现以下错误
An error occurred: ApiGatewayRestApi - You cannot change the endpoint of a RestApi to PRIVATE if there is a custom domain using it. (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException
我的 Serverless.yml 如下所示
custom:
customDomain:
domainName: my-api.${opt:stage}.example.com
basePath: 'v1'
stage: ${opt:stage}
createRoute53Record: true
certificateName: ${env.CERTIFICATE}
.......
provider:
name: aws
endpointType: PRIVATE
vpcEndpointIds:
- vpce-xxxxx
我该如何解决?
【问题讨论】:
-
您必须从您的 API 中删除您的自定义域。拥有 privet api 的公共域没有任何意义,因此您的转换被阻止。
-
好的,谢谢,那么有没有办法为我的 lambda 函数定义一个域名,假设我有 5 个 lambda 函数并且我希望使用用户可以理解的域名而不是亚马逊提供的域名来访问它们给我们?
-
我认为您可以使用 Route53 的私有托管区域名称。
标签: amazon-web-services aws-api-gateway serverless-framework