我正在开发多个函数,我们将使用这些函数来管理S3存储桶中的图像。我正在尝试弄清楚如何使用无服务器来将各种node.js脚本部署到lambda,到目前为止我已经弄清楚了这一部分。但我想将它们都部署为同一网关API下的不同路径。我尝试在provider部分下添加'apiName‘,但它只是创建了一个与第一个GatewayAPI同名的新as。
示例serverless.yml:
service: GetObjectInfo
frameworkVersion: ">=1.1.0"
custom:
region: us-east-2
provider:
name: aws
runtime: nodejs8.10
region: ${self:custom.region}
stage: ${opt:stage, 'dev'}
apiName: myGatewayAPI
memorySize: 256
timeout: 2
role: arn:aws:iam::118934906513:role/lambda-s3-role
functions:
GetObjectInfo:
name: GetObjectInfo
handler: index.handler
events:
- http:
path: /GetObjectInfo
method: POST
cors: true
environment:
REGION: ${self:custom.region}
package:
exclude:
- package-lock.json
- test/**
- .idea/**
- .git/**
- node_modules我在第二次/第三次/第n次中如何让他们将网关部分部署到相同的网关接口中?出于维护的目的,我更喜欢将lambda代码放在单独的project/git文件夹中。
发布于 2019-09-18 23:33:08
我认为默认情况下,无服务器框架会在同一个API Gateway下创建所有函数。
例如,以下代码应该可以工作:
custom:
region: us-east-2
provider:
name: aws
runtime: nodejs8.10
region: ${self:custom.region}
stage: ${opt:stage, 'dev'}
memorySize: 256
timeout: 2
role: arn:aws:iam::118934906513:role/lambda-s3-role
functions:
GetObjectInfo:
name: GetObjectInfo
handler: index.handler
events:
- http:
path: /GetObjectInfo
method: POST
cors: true
environment:
REGION: ${self:custom.region}
PutObjectInfo:
name: PutObjectInfo
handler: index.handlerPut
events:
- http:
path: /PutObjectInfo
method: PUT
cors: true
environment:
REGION: ${self:custom.region}https://stackoverflow.com/questions/57996178
复制相似问题