3
votes

Recently I use Serverless framework do create/deploy AWS lambda function / API gateway. It's a very cool way to deploy Lambda/API but I don't know how to apply it to existing AWS lambdas / APIs.

Is there any way to do it without drop the existing one then re-creating using serverless because i have dozens of existing lambda functions and apis.

2
thank you @mph85 but that ins't the solution i'm looking for - DonerKebab
np np, I'm misunderstanding then, what would prevent you from plugging in your existing Lambda function into AWS Lambda and letting the service take care of compiling it and all that? - mph85

2 Answers

0
votes

No. You can reuse the lambda functions by pointing to the specific ARN's of those functions within Serverless.yml, but there is currently no way to "replace" the API Gateway component without manual intervention and re-creation using Serverless.

The upside is, it should be relatively straightforward and easy to do unless you use features in AWS API Gateway currently not supported by the Serverless framework.

0
votes

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: ...