Recently, I came across a small project. The requirements were perfect for a serverless implementation described in AWS Lambda functions and invoking it using AWS API Gateway.

I started drawing the flow and realized that, after going live, I won’t be able to make incremental changes to the same function directly as it may impact the production.

That means I would need at least one more environment apart from production to be able to test the changes safely before going live.

The quickest option was to create a new lambda function and copy the same code and then make the changes. This would have worked but then I had to create a separate API in API Gateway to integrate with this new lambda function. It also increases maintenance efforts and costs.

After a bit of research, I found a better way :)

As a first step, you need to create just one function in AWS Lambda.

Choose the required runtime and deploy the code.

Test the function to make its working.

I’m assuming you already know how to do that and skipping the detailed steps :)

Publish a new version

Go to the AWS Lambda function in AWS,

  • Scroll to the top and locate the “Actions” dropdown.
  • Click to expand it and choose “Publish new version”

Image for post

  • Enter a short description of the changes you made and click the “Publish” button

Image for post

#serverless #aws-lambda #versioning #aws-api-gateway

AWS API Gateway — Integrate Environments to Different Versions of the Same Lambda Function
1.10 GEEK