In the below discussion, I will be discussing: (TL;DR) we can accomplish the above by using API Gateway’s stage variables, Lambda’s aliases, and Lambda’s version. I will demonstrate by the first approach with a single Lambda function, We shall create the lambda function we notice that it is automatically assigned to the $LATEST version.

We will also be using this alias in the API Gateway for different environments to reference the correct lambda version. In this case, we will create an alias ‘demo’ that points to version 1

In Conclusion, we will push the updated code to the respective branches and the pipeline will perform the deployment according to the branch.