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 setup Amazon Kinesis Data Stream with Amazon Pinpoint (Part 3)?

In this article, we will discuss "How to setup Amazon Kinesis Data Stream with Amazon Pinpoint (Part 3)?". This article is the third part of our Amazon Pinpoint Series. For better understanding, I recommend to readout the previous article. How to Setup AWS Pinpoint (Part 1) How to Setup AWS Pinpoint SMS Two-Way Communication (Part 2)? Streaming Amazon Pinpoint events to Kinesis In Amazon Pinpoint, when we send a transactional SMS or email message then an event will occur as per the action performed. In a simple way, Amazon Pinpoint sends information about events to Amazon Kinesis. Which, we read and process as per our requirement. We are talking about the SMS so we read the stream data to fetch the delivery reports of our SMSs. There are two types of streams given by the Amazon Kinesis such as Data Firehose, and Data Streams. Amazon Pinpoint can also stream data to Kinesis Data Streams, which ingests and stores multiple data streams for processing by analytics applications. F...

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