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

Laravel Logging Guzzle Requests in File

In this article, we will discuss “Laravel Logging Guzzle Requests in File”. In the multiple scenarios, we have to use third-party API’s in our project and test those API using postman or any other tool. But also required to maintain a log for each request, such as what we send (request)? and what we receive (response)? Today, […] Read out the full post at here

How to Use SSH with AWS EC2 Instance?

In this article, we will discuss "How to Use SSH with AWS EC2 Instance?" . As I already explain the setup of EC2 Instance and the use of an Elastic IP in my previous article. Today, we will learn how to connect an EC2 instance using SSH. If still, you have not read my previous articles then I recommend checking them once for a better understanding. Prerequisites A running EC2 Instance . Elastic IP (Optional for this article) ".pem" file, which is downloaded when setup the EC2 Instance. If not having the ".pem" file, then you have to create new key/value pairs. Connect via Terminal or WSL(Window Subsystem for Linux) Open your terminal and go to the directory where you downloaded your ".pem" file. Use the following command to connect with the server. ssh -i "****.pem" username@<publicDNS> or <IP Address> The same terminal command can be used in the windows Linux terminal. I'm using ubuntu on my windows machine...

How to Setup and Install Next.js App?

In this article, we will discuss "How to Setup and Install Next.js App" from scratch. What is React.js and Next.js? "React.js" is a JavaScript library for building user interfaces (elements that users see and interacting on-screen). Basically, React provide us some helpful functions to build UI, and leaves it on us where to use those functions in the application. "Next.js" is a React framework. It is maintained by "Vercel" . Next.js features to solve common application requirements such as routing, data fetching, integrations - all while improving the developer and end-user experience. Why we use Next.js ? Next.js comes with the some additional features to solve come application requirements such as: We can build SSG (Static Site Generation), SSR (Server-Side Rendering) and SPA (Single Page Application) apps. Hot code Reloading: Reload the page when it detects any change saved. Routing: No need to configure any route. Files put in the pages fol...