1 00:00:01,080 --> 00:00:02,260 - [Alana] In the beginning of the week, 2 00:00:02,260 --> 00:00:05,390 I referenced a situation where a team of engineers 3 00:00:05,390 --> 00:00:07,300 wanted to practice continuous delivery, 4 00:00:07,300 --> 00:00:09,420 on top of the continuous integration system 5 00:00:09,420 --> 00:00:11,620 they already had in place. 6 00:00:11,620 --> 00:00:13,570 At this point, we've spent most of the week learning 7 00:00:13,570 --> 00:00:15,090 how to get code deployed. 8 00:00:15,090 --> 00:00:16,423 However, we've still been 9 00:00:16,423 --> 00:00:18,490 performing these deployments manually, 10 00:00:18,490 --> 00:00:22,310 which doesn't really solve the scenario I presented earlier. 11 00:00:22,310 --> 00:00:23,720 The goal of that team of engineers 12 00:00:23,720 --> 00:00:25,700 was to automate their build, test, 13 00:00:25,700 --> 00:00:28,470 and then deploy that code to a staging environment 14 00:00:28,470 --> 00:00:31,920 before it gets released, all automated. 15 00:00:31,920 --> 00:00:34,330 So, let's figure out how to do that with the information 16 00:00:34,330 --> 00:00:36,093 and services we know, so far. 17 00:00:37,370 --> 00:00:40,160 So, here I am in the AWS Management Console, 18 00:00:40,160 --> 00:00:41,960 and I've already set up a sample pipeline 19 00:00:41,960 --> 00:00:44,750 that looks like what the team already has in place. 20 00:00:44,750 --> 00:00:46,815 For this, I use AWS CodePipeline to model 21 00:00:46,815 --> 00:00:49,500 and configure the different stages 22 00:00:49,500 --> 00:00:52,020 of the team software-release process. 23 00:00:52,020 --> 00:00:54,840 Since they're already practicing continuous integration, 24 00:00:54,840 --> 00:00:57,570 it's likely that the team had a source phase 25 00:00:57,570 --> 00:00:59,530 and a test phase. 26 00:00:59,530 --> 00:01:00,930 As you can see, I've already set up 27 00:01:00,930 --> 00:01:03,280 the source stage to use AWS CodeCommit, 28 00:01:03,280 --> 00:01:07,670 and a test stage to run unit tests on their site. 29 00:01:07,670 --> 00:01:10,030 Now, we just need to configure a deploy stage 30 00:01:10,030 --> 00:01:12,890 to automate the deployment all the way from the repository 31 00:01:12,890 --> 00:01:15,150 to their staging environment. 32 00:01:15,150 --> 00:01:15,983 Okay. 33 00:01:15,983 --> 00:01:16,950 So, to make this quick, 34 00:01:16,950 --> 00:01:18,740 I've already created an application 35 00:01:18,740 --> 00:01:20,890 and a deployment group for CodeDeploy. 36 00:01:20,890 --> 00:01:23,273 So, I'll go ahead and edit the pipeline. 37 00:01:24,540 --> 00:01:26,950 And I'm going to add in a deployment. 38 00:01:26,950 --> 00:01:29,430 I'll click Add stage in the pipeline, 39 00:01:29,430 --> 00:01:33,060 after the test stage, and call it Staging, 40 00:01:33,060 --> 00:01:35,053 and then click Add stage again. 41 00:01:36,370 --> 00:01:40,000 From here, I'll go ahead and click Add action group. 42 00:01:40,000 --> 00:01:42,510 And this is where I'll specify what kind of action 43 00:01:42,510 --> 00:01:44,724 I want to take here, and which service 44 00:01:44,724 --> 00:01:46,470 I'm going to use to do it. 45 00:01:46,470 --> 00:01:48,128 I'll give it a name, call it something, 46 00:01:48,128 --> 00:01:50,602 like DeployToStaging. 47 00:01:51,760 --> 00:01:53,790 I'll select the service I want to use, 48 00:01:53,790 --> 00:01:56,460 which, in this case, will be CodeDeploy. 49 00:01:58,080 --> 00:02:01,195 And then, I'll then specify the input artifact that flows 50 00:02:01,195 --> 00:02:02,453 through the pipeline. 51 00:02:03,400 --> 00:02:05,341 If you remember, in an earlier video, 52 00:02:05,341 --> 00:02:07,299 where we walked you through CodeDeploy, 53 00:02:07,299 --> 00:02:09,480 we use the service by itself. 54 00:02:09,480 --> 00:02:11,300 When we used it as a standalone service, 55 00:02:11,300 --> 00:02:13,830 we had to specify the location of the artifact 56 00:02:13,830 --> 00:02:16,810 and an S3 bucket that we created. 57 00:02:16,810 --> 00:02:18,810 When you create a pipeline with CodePipeline, 58 00:02:18,810 --> 00:02:21,140 it creates an artifact bucket by default, 59 00:02:21,140 --> 00:02:24,680 and uses this bucket to store input and output artifacts, 60 00:02:24,680 --> 00:02:28,710 and also transfers them from stage to stage on your behalf. 61 00:02:28,710 --> 00:02:32,690 In fact, we can go into the S3 console and see this bucket. 62 00:02:32,690 --> 00:02:35,330 I'll go ahead and search for this bucket, 63 00:02:35,330 --> 00:02:37,563 with CodePipeline in the title. 64 00:02:39,470 --> 00:02:42,250 And then, I'll choose the one for the Region I'm in. 65 00:02:42,250 --> 00:02:44,290 In this case, it'll be us-west-2, 66 00:02:44,290 --> 00:02:45,340 and I'll click on it. 67 00:02:46,220 --> 00:02:48,650 I can select which pipeline I want, here. 68 00:02:48,650 --> 00:02:49,580 And, in this case, 69 00:02:49,580 --> 00:02:52,690 I'm using the CDpipeline in this demo. 70 00:02:52,690 --> 00:02:55,010 And then, I can view the files in it. 71 00:02:55,010 --> 00:02:56,859 As you can see here, there is a folder 72 00:02:56,859 --> 00:02:58,359 that has our source artifacts, 73 00:02:58,359 --> 00:03:01,753 which CodePipeline will transfer from stage to stage. 74 00:03:03,058 --> 00:03:03,891 All right. 75 00:03:03,891 --> 00:03:06,850 So, let's go back to the CodePipeline console, 76 00:03:06,850 --> 00:03:10,360 where we're back to creating a DeployToStaging action. 77 00:03:10,360 --> 00:03:13,830 If we use CodeDeploy with CodePipeline, as we're doing here, 78 00:03:13,830 --> 00:03:16,800 we'll simply specify the artifact that's in the bucket, 79 00:03:16,800 --> 00:03:19,083 and it takes care of the rest. 80 00:03:19,083 --> 00:03:22,510 I'll select the details about the application name, 81 00:03:22,510 --> 00:03:23,760 and deployment group. 82 00:03:24,810 --> 00:03:26,093 And then, I'll click Done. 83 00:03:27,550 --> 00:03:28,550 All right. 84 00:03:28,550 --> 00:03:31,533 From here, I'll click Save, and then Save again. 85 00:03:34,040 --> 00:03:35,040 Okay. 86 00:03:35,040 --> 00:03:37,850 And then we'll kick off the pipeline once more. 87 00:03:37,850 --> 00:03:40,700 So, I'll go into my terminal, here. 88 00:03:40,700 --> 00:03:42,950 I'll find my application, 89 00:03:42,950 --> 00:03:45,564 which is index.html, here. 90 00:03:45,564 --> 00:03:47,732 I'll make a change to the file, 91 00:03:47,732 --> 00:03:50,849 such as changing the font-size. 92 00:03:50,849 --> 00:03:51,960 (typing) 93 00:03:51,960 --> 00:03:53,063 Save the file. 94 00:03:54,839 --> 00:03:56,530 (typing) 95 00:03:58,330 --> 00:04:01,553 And then, I will git add the file, 96 00:04:01,553 --> 00:04:03,163 (typing) 97 00:04:03,163 --> 00:04:07,973 git commit with a message, such as, "changed the font size," 98 00:04:07,973 --> 00:04:09,264 (typing) 99 00:04:10,760 --> 00:04:12,160 and git push. 100 00:04:15,700 --> 00:04:16,780 Okay. 101 00:04:16,780 --> 00:04:18,380 So, once we've updated the file, 102 00:04:18,380 --> 00:04:21,190 we can go back to our pipeline, here. 103 00:04:21,190 --> 00:04:23,533 And I will give it a bit to run. 104 00:04:25,340 --> 00:04:26,173 All right. 105 00:04:26,173 --> 00:04:28,720 So, it looks like everything's succeeded here, 106 00:04:28,720 --> 00:04:31,530 and we've automated much of the process already. 107 00:04:31,530 --> 00:04:34,090 So, everything is good to go. 108 00:04:34,090 --> 00:04:36,710 Now, if we wanted the pipeline that released to production, 109 00:04:36,710 --> 00:04:40,240 we could simply add another stage here, to DeployToProd. 110 00:04:40,240 --> 00:04:42,430 I've already created a pipeline that adds on to this, 111 00:04:42,430 --> 00:04:43,860 that does just that. 112 00:04:43,860 --> 00:04:46,003 So, I'll go ahead and find that pipeline, 113 00:04:48,370 --> 00:04:49,203 click on it, 114 00:04:49,203 --> 00:04:51,730 and we can view the entire thing. 115 00:04:51,730 --> 00:04:54,470 Here is my source, test, 116 00:04:54,470 --> 00:04:59,030 the DeployToStaging, and then the DeployToProd. 117 00:04:59,030 --> 00:05:02,400 But, notice in the middle of these two deploy stages, 118 00:05:02,400 --> 00:05:04,750 I have a manual approval action. 119 00:05:04,750 --> 00:05:07,140 This is the point where I want the pipeline to stop 120 00:05:07,140 --> 00:05:11,810 so that someone can manually approve or reject this action. 121 00:05:11,810 --> 00:05:14,080 If everything looks good, it can be released. 122 00:05:14,080 --> 00:05:16,773 Otherwise, we'll need to troubleshoot and fix. 123 00:05:18,090 --> 00:05:21,600 This entire pipeline here is continuous delivery in action. 124 00:05:21,600 --> 00:05:24,030 It automates the deployment to the staging environments, 125 00:05:24,030 --> 00:05:27,040 and includes a manual step here to DeployToProd. 126 00:05:27,040 --> 00:05:28,690 So, with this pipeline in place, 127 00:05:28,690 --> 00:05:31,553 the team is now practicing continuous delivery.