Instructor: 0:00 We have a Lambda function with two different versions. There's version 1 and version 2. In order to use those different versions in our code, we have to point our backend towards either version 1 or version 2.
0:11 In order to do that, we have to use something that is called an Amazon Resource Name. We can see that over here. Every single Amazon Web Services resource has a unique resource name that, for instance, we can see it over here for the version 1, and it's going to be different for version 2.
0:27 What if we wanted to have a single resource name that we can use, in order to call the version 1 or version 2, 50 percent of the time? In order to do that, we have to use aliases. In order to create a new alias, go to Actions, Create alias. I'm going to call it production-test, and I'm going to put it to the version 1.
0:47 You can also shift traffic between two versions, based on the weights and the percentage that you assign. I can click on Additional version, select 2, and it's going to be called 50 percent of the time, which is useful if you want to do some sort of AB testing, for instance, on production.
1:02 Now we can see that our alias has been successfully created. Let's test it. I'm going to close the test event. Here in the details, we can see that I've currently called the version 2. If I call it again, it's going to be going to calling the version 1, because it's going to call each one of those versions 50 percent of the time.
1:19 Aliases are not only useful for this kind of testing. If I were to go over here to the latest version and create a version 3 of this function, like this, save it, and create a new version by publishing it, version number 3, right now, I can point this alias that I've created.
1:39 Go to aliases, production-test, and I'm going to switch it. It's going to either call the version 3 or the version 2 of this function, 50 percent of the time. It is going to keep exactly the same Amazon Resource Name, which is very useful, because now we can update our versions without having to modify the code that is actually going to call this alias.
2:01 If I test it now, expand details, I'm going to see that it is either version 2 or version 3 that is being called.