Creating the CodeDeploy application

Now that we launched EC2 instances with the CodeDeploy service running on them and have defined our IAM service role, we have all the requirements needed to create a CodeDeploy application. As always, there are many ways to use AWS services, but we will demonstrate here the basics with the web interface:

  1. Open https://console.aws.amazon.com/codedeploy in your browser.
  2. If prompted, click on Get Started Now.
  3. This leads us to a welcome screen with two options, Sample Deployment or Custom Deployment. Choose Custom Deployment and click on Skip Walkthrough. This brings us to a form called Create New Application.
  4. In that form, under Application Name, give our application the name helloworld.
  5. The deployment groups can be viewed as the environment in which the application will live. We will first create a staging environment, therefore, under Deployment Group Name, and provide the name staging.

 

  1. We now need to add instances to our application. Our goal is to target the EC2 instance we previously created with CloudFormation. As you might recall, we called our stack helloworld-staging. In the section Add Instances Under the Search by Tags, keep the Amazon EC2 tag type selected and type helloworld-staging in the Value field. Optionally, you can also provide the Key aws:cloudformation:stack-name, which will make sure that CodeDeploy only selects the instance we intend to use for our application. AWS CodeDeploy should confirm that it matched one instance:
  1. The next section is called deployment configuration. One of the strengths of CodeDeploy is its ability to understand how to deploy code to a cluster of servers. Thanks to that feature, avoiding outages during deployment is easy. By default, the service comes with three deployment options: one at a time, all at once, and half at a time. It is possible to create custom deployment configurations, but in our case, since we have only one instance, we can leave the default option CodeDeployDefault.OneAtATime.
  2. The next two sections are called triggers and alarms. We aren't going to cover it in the book, but those triggers are key when it comes to collecting metrics around deployment and monitoring. By creating triggers to push notifications in SNS and creating CloudWatch metrics, you can easily collect metrics around deployments and answer questions like, How many deployments are happening?, How many fail?, How many deploys lead to rollback?, and so on.
  3. Our application is somewhat stateless, therefore enabling rollback upon failure is a very safe operation. Select the option Roll back when a deployment fails.
  4. Lastly, we need to select the service role we created in the previous steps. Under Service Role ARN, select the role that ends with CodeDeployServiceRole.
  5. Finally, click on Create Application.

This brings us back to the CodeDeploy application page for our newly created Hello World application.

Creating the application in CodeDeploy allows us to define where our newly created application will be deployed. We will now look at how to deploy our code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset