1 00:00:00,230 --> 00:00:02,510 ‫So let's have a look at a few more concepts for, 2 00:00:02,510 --> 00:00:05,130 ‫CodeDeploy. So when we approach an EC2 instance, 3 00:00:05,130 --> 00:00:07,610 ‫we're going to have the appspec.yml 4 00:00:07,610 --> 00:00:11,070 ‫at the root of your code and then deployment strategy. 5 00:00:11,070 --> 00:00:12,590 ‫So we can do, for example, 6 00:00:12,590 --> 00:00:15,740 ‫in place updates to your fleet of EC2 instances, 7 00:00:15,740 --> 00:00:16,750 ‫and then we can use hooks. 8 00:00:16,750 --> 00:00:19,510 ‫We set them in the expert Hemel to verify the deployments 9 00:00:19,510 --> 00:00:21,360 ‫after each deployment phase. 10 00:00:21,360 --> 00:00:22,880 ‫So here we have a half at a time. 11 00:00:22,880 --> 00:00:25,390 ‫So half of them is going to be taken down, 12 00:00:25,390 --> 00:00:27,190 ‫then upgraded to version two. 13 00:00:27,190 --> 00:00:29,240 ‫The other half is going to be taken down. 14 00:00:29,240 --> 00:00:30,110 ‫I've got your version two, 15 00:00:30,110 --> 00:00:32,003 ‫and this is an in-place deployment. 16 00:00:32,860 --> 00:00:34,640 ‫Now for ASG deployments of code, 17 00:00:34,640 --> 00:00:36,752 ‫the deployment's a little bit more complicated. 18 00:00:36,752 --> 00:00:37,585 ‫So we have two options. 19 00:00:37,585 --> 00:00:38,893 ‫We have in-place deployments and blue/green. 20 00:00:38,893 --> 00:00:41,870 ‫So in-place we'll be doing the exact same thing we saw 21 00:00:41,870 --> 00:00:44,425 ‫before. It will update existing EC2 instances. 22 00:00:44,425 --> 00:00:48,910 ‫And in case you create a new EC2 instances in your ASG 23 00:00:48,910 --> 00:00:51,170 ‫automatically, it's going to get a deployment 24 00:00:51,170 --> 00:00:52,960 ‫by CodeDeploy, which is very nice. 25 00:00:52,960 --> 00:00:56,090 ‫So this is where it could differ with ASG is very powerful. 26 00:00:56,090 --> 00:00:57,350 ‫So this is for in-place deployment, 27 00:00:57,350 --> 00:01:00,830 ‫but we also have blue/green deployments. And in this case, 28 00:01:00,830 --> 00:01:03,530 ‫a new auto-scaling group is going to be created and settings 29 00:01:03,530 --> 00:01:05,450 ‫are going to be copied. Then we get to choose 30 00:01:05,450 --> 00:01:07,540 ‫how long do you keep the old EC2 instances, 31 00:01:07,540 --> 00:01:11,600 ‫you old ASG. And then the ELB, that redirects 32 00:01:11,600 --> 00:01:13,960 ‫from one target group to the other, is 33 00:01:13,960 --> 00:01:16,040 ‫going to fall over. So let's set an example. 34 00:01:16,040 --> 00:01:18,530 ‫So this is our blue/green deployments or the ELB. 35 00:01:18,530 --> 00:01:21,650 ‫We have our EC2 instances on launch template V1 within 36 00:01:21,650 --> 00:01:23,000 ‫the ASG, 37 00:01:23,000 --> 00:01:25,560 ‫and then CodeDeploy is going to deploy the V1 38 00:01:25,560 --> 00:01:27,930 ‫application to these EC2 instances. Now, 39 00:01:27,930 --> 00:01:30,160 ‫in case we want to upgrade to version two, 40 00:01:30,160 --> 00:01:32,580 ‫then new instances are going to be created. 41 00:01:32,580 --> 00:01:34,800 ‫And then with launch pad V2, CodeDeploy 42 00:01:34,800 --> 00:01:38,069 ‫is going to deploy the application to these EC2 instances. 43 00:01:38,069 --> 00:01:42,980 ‫Then the ELB is going to receive traffic from both the V1 44 00:01:42,980 --> 00:01:45,400 ‫and V2 instances for says for a bit, 45 00:01:45,400 --> 00:01:49,020 ‫then, if everything is healthy, V version one will be taken 46 00:01:49,020 --> 00:01:53,290 ‫down and we will have done a blue/green deployment. 47 00:01:53,290 --> 00:01:55,060 ‫Finally, around the redeploys and rollbacks. 48 00:01:55,060 --> 00:01:56,380 ‫So a rollback is when, 49 00:01:56,380 --> 00:01:59,500 ‫when you want to redeploy a previously deployed revision 50 00:01:59,500 --> 00:02:02,042 ‫of your application, so you want to go back in time, 51 00:02:02,042 --> 00:02:04,670 ‫and deployments can be rolled back in two ways: 52 00:02:04,670 --> 00:02:06,350 ‫either automatically, for example, 53 00:02:06,350 --> 00:02:09,260 ‫when we have a failure of the deployment or when we have a 54 00:02:09,260 --> 00:02:11,360 ‫CloudWatch Alarm that is being triggered and say, 55 00:02:11,360 --> 00:02:14,450 ‫Hey the deployment has failed, or manually. 56 00:02:14,450 --> 00:02:15,710 ‫If we disable rollbacks, 57 00:02:15,710 --> 00:02:17,280 ‫then there will be no rollbacks performed 58 00:02:17,280 --> 00:02:18,850 ‫for this deployment. Okay? 59 00:02:18,850 --> 00:02:20,600 ‫And when the rollback happens, 60 00:02:20,600 --> 00:02:22,866 ‫what happens is that CodeDeploy actually redeploys the 61 00:02:22,866 --> 00:02:27,050 ‫last known good revision as a new deployment, okay, 62 00:02:27,050 --> 00:02:28,210 ‫it doesn't go back in time. 63 00:02:28,210 --> 00:02:31,370 ‫It actually performs a new deployment with a last known good 64 00:02:31,370 --> 00:02:34,260 ‫version that was known to do a good deployment. 65 00:02:34,260 --> 00:02:35,600 ‫So it's not a restored version. 66 00:02:35,600 --> 00:02:37,000 ‫It's definitely a new deployment, 67 00:02:37,000 --> 00:02:39,340 ‫and this is something that exam may test you on. 68 00:02:39,340 --> 00:02:41,520 ‫So that's it for this lecture, very theory, but I know, 69 00:02:41,520 --> 00:02:43,300 ‫but it's going to be helpful for your exam. 70 00:02:43,300 --> 00:02:46,250 ‫I hope you liked it and I will see you in the next lecture.