Create different versions of an AWS Lambda function

Tomasz Łakomy
InstructorTomasz Łakomy
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

It's awesome that we can edit a lambda function either directly in the AWS Console, or by uploading a new zip file or uploading it to an S3 bucket whenever we want.

Although at some point we'd like to effectively "freeze" a function to ensure that no one can modify it anymore, for instance when we want to deploy this function to a production environment.

In this lesson we're going to learn how to create different immutable versions of an AWS Lambda function, how to switch between them and how to call them separately

Instructor: [0:00] Start by creating a new Lambda function. I'm going to go ahead and call this function versions, and I'm going to create it. Let's create a default test event so we can call this function. I'm going to call this event myTestEvent and save it.

[0:15] You will notice that every single time we'll create a Lambda function, we are able to go ahead over here and add a console.log or something. In other words, we can edit and save this function.

[0:26] What if we want to have an immutable version of this function? In other words, we would like to be able not to modify this function because, for instance, we're going to deploy it to our production environment.

[0:35] In order to do that we have to use version. You can find the different versions of your Lambda functions under qualifiers. Over here, we can see that we have already a $LATEST version. You will always have the $LATEST version by default. This is the only version that you are allowed to modify.

[0:50] Let's modify this function by adding event version 1. Save this function, and I'm going to go to Actions and Publish a new version. I'm going to go to version 1 and publish it.

[1:04] Over here, we can see that I have successfully created version 1 of my function, which is called versions. As we discussed, I am not able to modify this code. Code and handle editing is only available for the latest versions.

[1:15] I can click here and go to $LATEST. I'm going to create an event version 2. Save this. I'm going to publish a new version which I'm going to call version 2. Publish it.

[1:31] Right now, we have two different versions of this function. If I were to call this one and check out the details, I'm going to see over here in the log that I am calling the version 2. if I were to switch to the version 1 and call this function, I'm going to see that I'm calling the version 1. I am not able to modify either version 1 or version 2.

egghead
egghead
~ 4 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today