1 00:00:01,410 --> 00:00:03,904 ‫Has an integration with CodeDeploy. 2 00:00:03,904 --> 00:00:05,820 ‫And CodeDeploy can help you automate 3 00:00:05,820 --> 00:00:08,460 ‫the traffic shift for your Lambda aliases. 4 00:00:08,460 --> 00:00:11,700 ‫So it builds onto the versions and aliases. 5 00:00:11,700 --> 00:00:14,250 ‫Now, we won't do in the hands-on in this lecture, 6 00:00:14,250 --> 00:00:17,250 ‫but the CodeDeploy feature is integrated 7 00:00:17,250 --> 00:00:18,240 ‫within the SAM framework. 8 00:00:18,240 --> 00:00:19,260 ‫And when we go and see 9 00:00:19,260 --> 00:00:21,600 ‫the Serverless Application Model frameworks, or SAM, 10 00:00:21,600 --> 00:00:24,090 ‫we will practice the CodeDeploy deployment 11 00:00:24,090 --> 00:00:25,470 ‫for your Lambda functions. 12 00:00:25,470 --> 00:00:27,420 ‫But I will still give you the idea right now. 13 00:00:27,420 --> 00:00:30,990 ‫So we have a PROD Alias, and say we want to upgrade it 14 00:00:30,990 --> 00:00:33,030 ‫from the Lambda function Version 1 15 00:00:33,030 --> 00:00:34,920 ‫to the lambda function Version 2. 16 00:00:34,920 --> 00:00:39,920 ‫So we want to shift the traffic from 100% of V1 to V2. 17 00:00:40,430 --> 00:00:43,950 ‫CodeDeploy will be making the X, in this example, 18 00:00:43,950 --> 00:00:46,980 ‫vary over time until X equals 100. 19 00:00:46,980 --> 00:00:49,560 ‫So that means that X will be first equal to 10%. 20 00:00:49,560 --> 00:00:52,620 ‫And so we'll have 90% on V1 and 10% on V2. 21 00:00:52,620 --> 00:00:53,880 ‫Then maybe 50%. 22 00:00:53,880 --> 00:00:56,307 ‫So we'll have 50% on V1 and 50% on V2. 23 00:00:56,307 --> 00:01:01,307 ‫And we finally, all the way up to 100% on V2 and 0% on V1. 24 00:01:01,680 --> 00:01:04,140 ‫So what strategies that CodeDeploy have? 25 00:01:04,140 --> 00:01:05,310 ‫Well, there is Linear, 26 00:01:05,310 --> 00:01:09,000 ‫to grow traffic every N minutes until 100%. 27 00:01:09,000 --> 00:01:09,870 ‫So we have the strategy 28 00:01:09,870 --> 00:01:12,561 ‫called Linear10PercentEvery3Minutes. 29 00:01:12,561 --> 00:01:15,240 ‫Linear10PercentEvery10Minutes, so this is pretty explicit. 30 00:01:15,240 --> 00:01:19,770 ‫And then we have Canary, where We try X% 31 00:01:19,770 --> 00:01:21,780 ‫and then we switch to 100%. 32 00:01:21,780 --> 00:01:23,430 ‫So we have Canary10Percent5Minutes. 33 00:01:23,430 --> 00:01:27,300 ‫So five minutes, there will be 10% of the traffic on V2. 34 00:01:27,300 --> 00:01:28,470 ‫And right after, oof, 35 00:01:28,470 --> 00:01:31,230 ‫you will switch to 100% of traffic on V2. 36 00:01:31,230 --> 00:01:33,330 ‫Or we can have Canary10PercentEvery30Minutes. 37 00:01:33,330 --> 00:01:34,163 ‫And then finally, 38 00:01:34,163 --> 00:01:36,750 ‫we have AllAtOnce for immediate traffic shift 39 00:01:36,750 --> 00:01:37,980 ‫between V1 and V2. 40 00:01:37,980 --> 00:01:39,780 ‫This is the quickest and most dangerous 41 00:01:39,780 --> 00:01:42,420 ‫because if we haven't tested our V2 function, 42 00:01:42,420 --> 00:01:43,860 ‫then things can fail. 43 00:01:43,860 --> 00:01:45,300 ‫So what about a rollback? 44 00:01:45,300 --> 00:01:48,120 ‫We can create pre and post traffic hooks 45 00:01:48,120 --> 00:01:50,250 ‫to check the health of our land function. 46 00:01:50,250 --> 00:01:52,530 ‫And the idea is that if anything goes wrong, 47 00:01:52,530 --> 00:01:55,440 ‫then the traffic hooks can be failing 48 00:01:55,440 --> 00:01:57,450 ‫or a CloudWatch alarm can be failing, 49 00:01:57,450 --> 00:02:00,300 ‫and your CodeDeploy can know that something is going wrong. 50 00:02:00,300 --> 00:02:02,340 ‫And therefore, it will do a rollback 51 00:02:02,340 --> 00:02:05,310 ‫and put the traffic back all onto V1. 52 00:02:05,310 --> 00:02:06,930 ‫And if you're using AppSpec.yml 53 00:02:06,930 --> 00:02:09,240 ‫to deploy Lambda with CodeDeploy, 54 00:02:09,240 --> 00:02:11,670 ‫you have a few important parameters to know about. 55 00:02:11,670 --> 00:02:12,503 ‫There is the Name, 56 00:02:12,503 --> 00:02:14,610 ‫which is the name of the function to deploy. 57 00:02:14,610 --> 00:02:16,080 ‫The Alias, that's required, 58 00:02:16,080 --> 00:02:19,350 ‫which is the name of the alias of the Lambda function. 59 00:02:19,350 --> 00:02:21,270 ‫We have the CurrentVersion, 60 00:02:21,270 --> 00:02:23,610 ‫which is the version of the Lambda function 61 00:02:23,610 --> 00:02:25,860 ‫that the traffic currently points to. 62 00:02:25,860 --> 00:02:27,330 ‫And the TargetVersion, 63 00:02:27,330 --> 00:02:29,160 ‫which is the version of the Lambda function 64 00:02:29,160 --> 00:02:31,620 ‫that the traffic is going to be shifted to. 65 00:02:31,620 --> 00:02:34,650 ‫And then CodeDeploy is going to update the alias 66 00:02:34,650 --> 00:02:36,870 ‫from Version 1 to Version 2, 67 00:02:36,870 --> 00:02:40,140 ‫from the CurrentVersion to the TargetVersion over time. 68 00:02:40,140 --> 00:02:41,340 ‫So that is the whole integration 69 00:02:41,340 --> 00:02:42,750 ‫between Lambda and CodeDeploy. 70 00:02:42,750 --> 00:02:44,910 ‫We won't be practicing this in this lecture. 71 00:02:44,910 --> 00:02:48,480 ‫But when we get to the SAM framework section, then we will. 72 00:02:48,480 --> 00:02:49,320 ‫Okay, that's it. 73 00:02:49,320 --> 00:02:51,070 ‫I will see you in the next lecture.