gpt4 book ai didi

aws-lambda - 如何将 Serverless 应用到现有的 API 网关

转载 作者:行者123 更新时间:2023-12-02 04:24:00 24 4
gpt4 key购买 nike

最近我使用 Serverless 框架来创建/部署 AWS lambda 函数/API 网关。这是部署 Lambda/API 的一种非常酷的方式,但我不知道如何将其应用于现有的 AWS lambdas/API。

有没有什么方法可以在不删除现有函数的情况下使用无服务器重新创建,因为我有几十个现有的 lambda 函数和 api。

最佳答案

https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#share-api-gateway-and-api-resources

As your application grows, you will likely need to break it out into multiple, smaller services. By default, each Serverless project generates a new API Gateway. However, you can share the same API Gateway between multiple projects by referencing its REST API ID and Root Resource ID in serverless.yml as follows:


service: service-name
provider:
name: aws
apiGateway:
restApiId: xxxxxxxxxx # REST API resource ID. Default is generated by the framework
restApiRootResourceId: xxxxxxxxxx # Root resource, represent as / path
websocketApiId: xxxxxxxxxx # Websocket API resource ID. Default is generated by the framework
description: Some Description # optional - description of deployment history

functions: ...

关于aws-lambda - 如何将 Serverless 应用到现有的 API 网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56591009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com