简体   繁体   English

使用无服务器向同一个网关API添加新的lambda函数?

[英]Using serverless to add new lambda functions to same Gateway API?

I'm working on multiple functions that we will be using to manage images in an S3 bucket. 我正在处理多个功能,我们将使用这些功能来管理S3存储桶中的图像。 I'm trying to figure out how to user serverless to deploy the various node.js scripts to lambda and thus far have figured that part out. 我正在尝试弄清楚如何无用户地将各种node.js脚本部署到lambda,到目前为止,已经弄清楚了这一部分。 But I would like to deploy them all as different paths under the same gateway API. 但是我想将它们全部部署为同一网关API下的不同路径。 I tried adding 'apiName' under the provider section, but it just creates a new GatewayAPI with the same name as the first. 我尝试在提供者部分下添加“ apiName”,但它只是创建了一个与第一个相同名称的新GatewayAPI。

Sample serverless.yml: 示例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

What do I do in a second/third/nth to get them to deploy the gateway part into the same gateway interface? 我要在第二/第三/第n次执行什么操作,以使他们将网关部件部署到同一网关接口中? I prefer to keep the lambda code in separate project/git folders for maintenance purposes. 我更喜欢将lambda代码保存在单独的project / git文件夹中,以进行维护。

I think the serverless framework creates all the functions under the same API Gateway by default. 我认为默认情况下,无服务器框架会在同一API网关下创建所有功能。

eg the following should work: 例如以下应该工作:

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}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将无服务器API网关URL作为同一堆栈中Lambda函数的参数传递 - Passing serverless API Gateway URL as a parameter for a Lambda function in the same stack 使用 API 网关和无服务器框架在 AWS Lambda 上超过了速率 - Rate Exceeded on AWS Lambda Using API Gateway and serverless framework 将 API 网关作为触发器添加到 Lambda Function 使用无服务器脚本而不是 UI - Adding API Gateway as Trigger to Lambda Function Using Serverless Script not the UI 使用与无服务器数据库对话的 Lambda function 集成的 AWS API 网关创建完全无服务器的解决方案 - Creating a completely serverless solution using AWS API Gateway integrated with a Lambda function that talks to a serverless database 具有 API 网关和 Lambda 的 Aurora Serverless 超时 - Aurora Serverless with API Gateway and Lambda is timing out 具有Lambda集成的无服务器部署API网关 - Serverless Deployment API Gateway with Lambda Integration 部署 lambda 函数时如何从无服务器获取 API 网关 ID 作为输出部分 - How to get API Gateway ID as output section from the serverless when lambda functions are deployed 如何将 AWS 无服务器应用程序项目更改为仅部署为 lambda 功能? (没有API网关和云编队) - How to change an AWS Serverless application project to just deploy as lambda functions? (No API gateway and cloud formation) AWS Aurora 无服务器 mysql、Cognito、Lambda、API 网关、CloudFormation 启动器 - AWS Aurora serverless mysql, Cognito, Lambda, API gateway, CloudFormation starter Terraform 无服务器应用程序与 AWS Lambda 和 API 网关未知令牌? - Terraform Serverless Applications with AWS Lambda and API Gateway unknown token?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM