node.js - 无服务器 : Deploy to same api from different yml

标签 node.js aws-api-gateway aws-cloudformation serverless-framework

我有 api api.demo

其结构如下

api.demo
   /service1:
     GET /test1
     GET /test2
     ...
  /service2
     GET /test1
     GET /test2
     ...

我有两个单独的文件夹service1、service2 每个都有自己的 serverless.yml 文件 当我部署时,它会在 api 网关中创建两个单独的 api,如下所示

api.demo(id1)
   /service1:
     GET /test1
     GET /test2
     ...
api.demo(id2)
   /service2
     GET /test1
     GET /test2

如何更新 service2 以采用相同的 api 端点 api.demo(id1)?

我怎样才能实现这个目标? 任何指示都会有帮助。

最佳答案

只需使用自定义域名:http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html

您可以将基本路径映射到 API,这样您就可以将 /service1 映射到第一个 API,将 /service2 映射到第二个 API。客户端将访问自定义域名,而不是我们提供的默认 execute-api 端点。

关于node.js - 无服务器 : Deploy to same api from different yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45453680/

相关文章:

amazon-web-services - 如何在 API 网关上受 Cognito 授权者保护的 lambda 函数内获取 AWS Cognito 用户数据

javascript - AWS 网关超时

amazon-web-services - AWS 步骤函数 - 转换 {AWS::AccountId}::StepFunctionsYamlTransform 失败,但没有错误消息

amazon-s3 - aws cloudformation 无法导入导出变量的 ImportValue

javascript - 执行 Firebase 事务时如何检查 Node 的值?

amazon-web-services - 配置 AWS::Serverless::Api 资源以进行 HTTP_PROXY 集成

python - 如何在 ReactJS Docker 中热重载

amazon-web-services - 如何知道从 aws sam 模板创建 aws 资源时返回哪些属性

javascript - 我的 js 文件中的数组未转换为 JSON

node.js - 在 Node 生成命令中回显 bash 变量