Start to get familiar with CodeDeploy by exploring concepts in this video.
- [Instructor] Now that we have a binary artifact that we can use, let's send it out to our virtual machine. CodeDeploy, as the name implies, is a service that helps us take our generated binaries, config files, and scripts to our servers. I use the word servers here because CodeDeploy requires an agent installed in our target machines. This is a good thing, because in addition to deploying to EC2 virtual machines, we can also deploy to traditional physical servers that are not in the cloud provided they have the CodeDeploy engine installed.
CodeDeploy also manages the deployment strategy to be used when deploying to several servers that share a workload inside an auto-scaling group. You can do your deployment all at once, half of your servers, or one-by-one. Even better, take full advantage of the cloud by doing a blue-green deployment, in which you deploy entirely new machines and only discard the old ones after the new deployment has been validated. For our demo, we have an EC2 Ubuntu Linux machine running Tomcat web server.
We will use CodeDeploy to take our code from where it is, to its final destination inside the web server, where it'll be picked up and executed. CodeDeploy requires a SIP archive to be passed as input. This archive will contain the appspec file, as well as our deployment package, in our case, a Java.war file. This is known as a revision. Should you ever need to use this tool in a standalone fashion, you would need to be able to provide your own revisions every time you want to do a deployment.
I wouldn't worry about this too much, because once we learn how to use CodePipeline, you'll notice that it takes care of passing the results directly from CodeBuild to CodeDeploy in a completely automated way. But for now, let's learn how to use this tool on its own. This is very important those of you that prefer to use Jenkins as your CICD pipeline orchestrator instead of CodePipeline. We're looking at another special config file here. This one is called appspec, or application specification file.
This asspspec file is checked in our code repository and CodeBuild includes it in the generative SIP archive as instructed to do so in the buildspec file. Similar to the buildspec file that CodeBuild uses, this one tells CodeDeploy what to do with our generated binaries and any additional files we may need, such as config files, scripts, and more. In our case, it's very simple. Take the web archive and copy it to the webapps folder of our Tomcat web server, where it will be picked up and deployed automatically by Apache Tomcat.
We specify the source name on line four, and where it will be copied to on line five. Let's set up CodeDeploy next.
- Checking in source code with CodeCommit
- Building code in CodeBuild
- Deploying code with CodeDeploy
- Creating a DevOps pipeline with CodePipeline
- Creating and deploying an Elastic Beanstalk application