Skip to main content

How to Manage AWS Lambda Versioning and Aliases

In this article, we will discuss "How to Manage AWS Lambda Versioning and Aliases". The use of AWS Lambda versioning and Aliases are the safest way to manage and deploy the Lambda functions. We can split our production and testing environment easily. No one can apply any kind of change in the published version, because of this our production published version is completely safe for an unwanted or accidental change. I will try to explain both ways such as GUI and Command-Line in this article.

Basic Understanding on AWS Lambda

Lambda Versions


Each of the Lambda versions has a unique ARN. For more details, check the official documentation for Lambda Versions. The function ARN will have a format such as:
arn:aws:lambda:us-east-1:xxxxxxxxxxxx:function:test_func:1

"xxxxxxxxxxxx" stands for the AWS account id, and test_func is a Lambda function name. The number 1 at the end of the ARN indicates the version. Also, possible to refer to a function's latest version:
arn:aws:lambda:us-east-1:xxxxxxxxxxxx:function:test_func:$LATEST

Consumers relying on the latest version will automatically use a new version once promoted to $LATEST. When the Lambda version is omitted, the ARN is said to be unqualified:
arn:aws:lambda:us-east-1:xxxxxxxxxxxx:function:test_func

For teams that decide not to use the AWS Lambda versioning system, the qualified or unqualified versions won't make any difference.

Publish Lambda Version using CLI


Using the AWS command-line interface, a version is published with the following command:
aws lambda publish-version --function-name test_func

Publish Lambda Version using GUI (AWS Management Console)


Open AWS Management Console and go to Lambda dashboard. Select the Lambda function and click on the versions tab as given below:



Click on the "Publish new version" button and add the version description. It's an optional requirement but I recommend adding a short description of that version.



Our function version "1" is published now.


Lambda Aliases


Similar to Lambda versions, aliases has a unique ARN. Each of the Aliases represents a specific version. We have to attach the version to the Lambda Aliases. For more details, check the official documentation for Lambda Aliases.

For example, a Lambda function has a PROD alias. The development team deploys a new version after the testing and then points the PROD alias to the new stable version. The function ARN will have a format such as:
arn:aws:lambda:us-east-1:xxxxxxxxxxxx:function:test_func:Prod

So when we publish a new version then we have to link that version with the alias.

Create Lambda Alias using CLI


Using the AWS command-line interface, an alias is created with the following command:
aws lambda create-alias --function-name test_func --function-version version 1 --name hello-alias --description "This is a 'Hello World' Alias"

Update Lambda Alias using CLI


Updating the version to which an alias points (to version 2, for example)
aws lambda update-alias --function-name test_func --name hello-alias --function-version 2

Create Lambda Alias using GUI (AWS Management Console)


Open AWS Management Console and go to Lambda dashboard. Select the Lambda function and click on the aliases tab as given below:



Click on the "Create alias" button and add the name and description. Again, description is an optional requirement but I recommend adding a short description of that alias. After that select the version from the given dropdown. This means your alias is linked with that version.



Our function alias "Prod" is created successfully.


Conclusion


In this article, we are discussing "How to Manage AWS Lambda Versioning and Aliases". I'm trying to explain to you about Lambda versioning and aliases, hope you like this article. Note that AWS provides us the easiest way to apply the configuration to specific versions and aliases such as permission, triggers or etc. Please feel free to add comments if any queries or suggestions.

Keep learning & stay safe ;)



You may like:


How to Setup AWS Pinpoint (Part 1)


Create AWS IAM User with Programmatic Access


How to Upload File to AWS S3 Bucket Laravel


Basic Understanding on AWS Lambda

Comments

Popular posts from this blog

Basic Use of Model Factories in Laravel

In this article, we will discuss the basic use of Model Factories in Laravel. Laravel comes with the feature called model factories that are offered to made fake models quickly. It’s used in the database testing and database seeding. Let’s start the discussion on this feature by... Read out the full post at here

How to Manage Elastic IP in AWS?

In this article, we will discuss "How to Manage Elastic IP in AWS?" . Here, you will learn the use of Elastic IP addresses and how to assign it to your EC2 Instance. If you are new with EC2 Instance then check out my previous article, "How to setup an EC2 Instance on AWS" . EC2 (Amazon Elastic Compute Cloud) provide us an ability to create, start, stop and terminate the instance at any time. This will creates a challenge with IP addresses, because restarting an instance or replacing a terminated instance with newly created instance, will result in a new IP address. Now the question is "How to reference a machine when the IP is constantly change?" . We can handle this situation with the use of Elastic IP address. We can associate a single Elastic IP address to different Ec2 Instances. You can immediately associate a new Ec2 Instance with the Elastic IP address if the EC2 instance is stopped or terminated. After the back-end EC2 instance changes, our exist...

How to use trackBy in Angular with Example

In this article, we will discuss "How to use trackBy in Angular" . Basically, " trackBy " is used to improve the performance of an angular application. Today, I will try to explain the use of trackBy with an example. Why do we need trackBy in Angular? By default, no need to use trackBy in Angular. But with large collections of data, angular ngFor directive may perform poorly. For example, a small change of data such as adding a new record, editing, or deleting a record from the collection. The angular framework will remove all the DOM elements that are associated with the data and will create them again in the DOM tree even if the same data is coming. Here, a lot of DOM manipulation will happen in the background if a large amount of data comes from the API then the application performance will suffer. Angular trackBy example Angular provides us function trackBy which helps us to track the items which have been added or deleted. The trackBy function takes two argum...