1 00:00:00,110 --> 00:00:01,480 ‫So let's talk about the concepts 2 00:00:01,480 --> 00:00:03,660 ‫of Lambda Version and Aliases. 3 00:00:03,660 --> 00:00:06,250 ‫So far when we've been working on the Lambda functions, 4 00:00:06,250 --> 00:00:09,500 ‫we used this &LATEST version. 5 00:00:09,500 --> 00:00:11,540 ‫So this version was immutable 6 00:00:11,540 --> 00:00:14,297 ‫because we were able to edit our code and so on. 7 00:00:14,297 --> 00:00:16,690 ‫But one thing we haven't done is 8 00:00:16,690 --> 00:00:18,670 ‫that when we're happy with our code states, 9 00:00:18,670 --> 00:00:20,760 ‫we can publish the Lambda function 10 00:00:20,760 --> 00:00:22,190 ‫and create a new version. 11 00:00:22,190 --> 00:00:23,660 ‫So as soon as we hit publish, 12 00:00:23,660 --> 00:00:25,410 ‫it will become V1 13 00:00:25,410 --> 00:00:27,290 ‫and V1 is immutable. 14 00:00:27,290 --> 00:00:28,500 ‫What does immutable mean? 15 00:00:28,500 --> 00:00:30,410 ‫That means that you cannot change the code 16 00:00:30,410 --> 00:00:31,930 ‫or the environment variables, 17 00:00:31,930 --> 00:00:33,690 ‫or anything else afterwards. 18 00:00:33,690 --> 00:00:36,380 ‫So it is fixed as a version. 19 00:00:36,380 --> 00:00:38,350 ‫And so as you keep on publishing, 20 00:00:38,350 --> 00:00:40,500 ‫the versions will have an increasing version numbers. 21 00:00:40,500 --> 00:00:42,650 ‫So you go from V1 to V2, 22 00:00:42,650 --> 00:00:44,180 ‫et cetera. 23 00:00:44,180 --> 00:00:46,330 ‫Each version is independence 24 00:00:46,330 --> 00:00:47,640 ‫and will get its own ARN, 25 00:00:47,640 --> 00:00:49,160 ‫so Amazon Resource Name. 26 00:00:49,160 --> 00:00:51,970 ‫And so if we do know whatever it is now, 27 00:00:51,970 --> 00:00:54,540 ‫it is your code and your configuration. 28 00:00:54,540 --> 00:00:55,450 ‫Nothing can be changed. 29 00:00:55,450 --> 00:00:56,540 ‫It's immutable. 30 00:00:56,540 --> 00:00:58,830 ‫So each Lambda function version, 31 00:00:58,830 --> 00:01:01,430 ‫can be accessed as well as your latest. 32 00:01:01,430 --> 00:01:03,090 ‫So this is great to iterate 33 00:01:03,090 --> 00:01:04,520 ‫and mark your advance 34 00:01:04,520 --> 00:01:07,270 ‫until it releases you Lambda function. 35 00:01:07,270 --> 00:01:09,180 ‫But what if he wants to give 36 00:01:09,180 --> 00:01:12,090 ‫your end user a standard endpoint? 37 00:01:12,090 --> 00:01:14,850 ‫So for this, we can use Lambda Aliases. 38 00:01:14,850 --> 00:01:16,690 ‫Aliases are going to be pointers, 39 00:01:16,690 --> 00:01:18,830 ‫that points to your Lambda function versions. 40 00:01:18,830 --> 00:01:20,490 ‫And we can define a DEV test 41 00:01:20,490 --> 00:01:21,530 ‫and PROD Aliases. 42 00:01:21,530 --> 00:01:23,400 ‫For example and have them point 43 00:01:23,400 --> 00:01:25,190 ‫to different Lambda versions. 44 00:01:25,190 --> 00:01:26,161 ‫Aliases this time are mutable 45 00:01:26,161 --> 00:01:28,460 ‫and this is why we want to use them. 46 00:01:28,460 --> 00:01:30,070 ‫And so we have the latest, 47 00:01:30,070 --> 00:01:31,490 ‫which is a version in Alias, 48 00:01:31,490 --> 00:01:32,430 ‫This is fine. 49 00:01:32,430 --> 00:01:34,790 ‫Then with V1 and V2. 50 00:01:34,790 --> 00:01:36,800 ‫And so we're going to create a DEV Alias. 51 00:01:36,800 --> 00:01:38,060 ‫That's going to be mutable 52 00:01:38,060 --> 00:01:40,060 ‫pointing to the latest version of Lambda function. 53 00:01:40,060 --> 00:01:41,300 ‫This way we can edit code 54 00:01:41,300 --> 00:01:43,080 ‫and quickly see how it's going on. 55 00:01:43,080 --> 00:01:45,490 ‫In our users will interact with a DEV Alias 56 00:01:45,490 --> 00:01:46,830 ‫which will in turn call 57 00:01:46,830 --> 00:01:48,950 ‫the latest version of our function. 58 00:01:48,950 --> 00:01:50,810 ‫But we can create a TEST Alias 59 00:01:50,810 --> 00:01:53,440 ‫to test the V2 version of our function. 60 00:01:53,440 --> 00:01:54,810 ‫Again, that's mutable. 61 00:01:54,810 --> 00:01:56,700 ‫And we can create a PROD Alias 62 00:01:56,700 --> 00:01:58,330 ‫two test and not two test 63 00:01:58,330 --> 00:02:01,040 ‫actually two points to the V1 function 64 00:02:01,040 --> 00:02:03,200 ‫that we know is stable and working. 65 00:02:03,200 --> 00:02:05,310 ‫So why do we do Aliases 66 00:02:05,310 --> 00:02:07,260 ‫Well they enable canary deployments 67 00:02:07,260 --> 00:02:08,361 ‫Because we can assign weights 68 00:02:08,361 --> 00:02:11,110 ‫to the Lambda function versions we point to. 69 00:02:11,110 --> 00:02:12,600 ‫So for PROD for example, 70 00:02:12,600 --> 00:02:13,830 ‫say we want to switch 71 00:02:13,830 --> 00:02:15,370 ‫from the V1 function 72 00:02:15,370 --> 00:02:17,230 ‫all the way to the V2 function. 73 00:02:17,230 --> 00:02:19,160 ‫Instead of switching the pointer, 74 00:02:19,160 --> 00:02:21,970 ‫we can say 95% of the traffic 75 00:02:21,970 --> 00:02:23,560 ‫is going to go to V1. 76 00:02:23,560 --> 00:02:27,620 ‫And only 5% of the traffic is going to go to V2. 77 00:02:27,620 --> 00:02:28,680 ‫And the purpose of this 78 00:02:28,680 --> 00:02:31,240 ‫is that now we're testing V2 in PROD, 79 00:02:31,240 --> 00:02:32,150 ‫making sure it works 80 00:02:32,150 --> 00:02:34,400 ‫before we switch the full power 81 00:02:34,400 --> 00:02:37,540 ‫onto V2 and 100% of the traffic there. 82 00:02:37,540 --> 00:02:40,280 ‫So Aliases, enable stable configuration 83 00:02:40,280 --> 00:02:42,640 ‫for our triggers or user destinations. 84 00:02:42,640 --> 00:02:44,320 ‫They can be invoked stably, 85 00:02:44,320 --> 00:02:45,780 ‫but they can point in the backend 86 00:02:45,780 --> 00:02:48,270 ‫to whatever Lambda version we want. 87 00:02:48,270 --> 00:02:50,858 ‫So these Aliases will get their own ARNs. 88 00:02:50,858 --> 00:02:52,880 ‫And the great thing to note, 89 00:02:52,880 --> 00:02:54,670 ‫Aliases cannot reference 90 00:02:56,667 --> 00:02:57,500 ‫other Aliases. 91 00:02:57,500 --> 00:02:58,700 ‫They can only reference version 92 00:02:58,700 --> 00:03:00,190 ‫and it's something the exam may 93 00:03:00,190 --> 00:03:01,380 ‫try to trick you on. 94 00:03:01,380 --> 00:03:02,213 ‫Okay. 95 00:03:02,213 --> 00:03:04,570 ‫So let's go into the hands-on to see how they work.