Lambda Alias and Versions

In the previous post, we looked at creating and deploying lambda functions. Deploying lambda functions is relatively straight forward. However, deployments can get tricky when there are many lambda functions, function code changes are frequent, and releases need to be tracked appropriately. This is where Lambda Aliases and Lambda Versions can make life easier. There are three elements and understanding these can help to refine lambda deployment process.

Lambda Function:
Lambda function refers to actual piece of code being deployed. This is function which gets executed when lambda is invoked. Every lambda function can be uniquely identified by ARN.

Lambda Version:
As name suggests, Lambda version refers to version of lambda function. One lambda function can have many lambda versions and every version gets a unique ARN (by appending version as suffix to actual lambda ARN). Every time you make a change in lambda function, you can create a new version and add relevant description to it (imagine information which will help to track releases). Every version can have different configuration and different environment variables.

Lambda Alias:
Lambda Alias is like abstraction layer or wrapper on lambda version. Alias points to specific lambda version. Lambda Aliases, along with lambda versions, significantly simplifies deployment process. Consider a scenario where a single lambda function is being invoked from multiple places: e.g. when PUT events happens in Bucket_1, when PUT event happens in Bucket_2 and when message arrives in SNS Topic_1. Moreover, same lambda might also be invoked by some java server. If it were not for aliases, every time a new version is deployed, we will have to change lambda ARN in access policies for all resources triggering lambda function. However, now we can create a Lambda Alias, e.g. prod, and prod alias can point to version 1. All services will be triggering lambda using ARN of alias. Now, version 2 of lambda is released, we just need to point prod alias to version 2. Permissions or triggering mechanisms of other Services invoking lambdas need no modification as access policies are referring to ARN of alias.

Further Reading:
Link 1
Link 2

Comments

Popular posts from this blog

Practice Questions - AWS Solutions Architect - Associate Certification

AWS Parameter Store

Continuous Integration using AWS CodePipeline (GitHub to Elastic BeanStalk)