Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Rolling Updates to a Highly Distributed Web Application with AWS CodeDeploy

A DevOps engineer needs to deploy an application to a fleet of existing servers within AWS. When the rollout is complete, they need to push out an update, without taking the application offline. In this lab, we will use AWS CodeDeploy to manage code deployments and updates to a fleet of EC2 instances running in an Auto Scaling group and presented behind an elastic load balancer.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 1h 0m
Published
Clock icon Nov 20, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create an S3 Bucket to Store Application Code

    1. Navigate to S3.
    2. Select Create bucket, and enter a unique bucket name. Make a note of this name. From now on in these lab instructions, we will call this our code bucket.
    3. In another browser tab, navigate to the GitHub repository for this course. You'll find a link in the resources section of the lab. Download the repository.
    4. Upload the two zip files into your code bucket.
  2. Challenge

    Create a CodeDeploy In-Place Deployment

    Create a CodeDeploy Application

    1. Navigate to the AWS CodeDeploy service page.
    2. Select Applications from the left-hand menu.
    3. Select Create application.
    4. For the Application name, enter "demo-app".
    5. For the Compute platform select EC2/On-premises.
    6. Select Create application.

    Create a CodeDeploy Deployment Group

    1. From the CodeDeploy applications details page, select Create deployment group.
    2. For the Deployment group name, enter "demo-group".
    3. For Service role, select the role created with this lab (the only option).
    4. For Deployment type, select In-place.
    5. For Environment configuration, select Amazon EC2 Auto Scaling groups.
    6. From the dropdown box, select Auto Scaling group la-scale-asg-, which should be the only option.
    7. Scroll down to Load balancer, and select Classic Load Balancer. Then, from the dropdown list, select la-lab (the only option).
    8. Select Create deployment group.

    Create a CodeDeploy Deployment

    1. From the CodeDeploy deployment group details page, select Create deployment.
    2. Ensure the Deployment group selected is demo-group.
    3. Ensure the Revision type selected is My application is stored in Amazon S3.
    4. For Revision location, enter the path of the SampleApp_Linux.zip object in your code bucket. For example: s3://code-bucket-123/SampleApp_Linux.zip.
    5. Scroll to Additional deployment behavior settings and under Content options, select Overwrite the content.
    6. Select Create deployment.
  3. Challenge

    Test the Deployed Application

    1. Navigate to the AWS EC2 console.
    2. Select Load Balancers from the left-hand menu.
    3. Select the Description tab, and copy the value for DNS name.
    4. Paste that value into a new browser tab.
    5. Ensure you can see the sample web application.
  4. Challenge

    Create a CodeDeploy Blue-Green Deployment

    Create a CodeDeploy Deployment Group

    1. Navigate to the AWS CodeDeploy service page.
    2. Select Applications from the left-hand menu, then select demo-app from the list of applications.
    3. From the CodeDeploy applications details page, select Create deployment group.
    4. For the Deployment group name, enter "demo-blue-green".
    5. For Service role select the role created with this lab (the only option).
    6. For Deployment type, select Blue/green.
    7. For Environment configuration, select Automatically copy Amazon EC2 Auto Scaling group.
    8. From the dropdown box, select Auto Scaling group la-scale-asg-, which should be the only option.
    9. From Deployment settings, ensure Reroute traffic immediately is selected, and ensure Terminate the original instances in the deployment group is selected, and that 0's (zeros) are in place for Days, Hours, and Minutes.
    10. Scroll down to Load balancer, select Classic Load Balancer and from the dropdown list select la-lab (the only option).
    11. Select Create deployment group.

    Create a CodeDeploy Deployment

    1. From the CodeDeploy deployment group details page, select Create deployment.
    2. Ensure the Deployment group selected is demo-blue-green.
    3. Ensure the Revision type selected is My application is stored in Amazon S3.
    4. For Revision location, enter the path of the SampleApp_Linux_update.zip object in your code bucket. For example: s3://code-bucket-123/SampleApp_Linux_update.zip.
    5. Scroll to Additional deployment behavior settings and under Content options, select Overwrite the content.
    6. Select Create deployment.

    Now wait for the deployment to complete.

  5. Challenge

    Test the Updated Application

    Note: This is a repeat of the previous testing step. If you have a browser tab open still from that testing, you may simply press refresh in your browser.

    1. Navigate to EC2.
    2. Select Load Balancers from the left-hand menu.
    3. Select the Description tab, and copy the value for DNS name.
    4. Paste that value into a new browser tab.
    5. Ensure you can see the sample web application.

    You should notice there is a mistake on the page: It says it's deployed with Azure! Next, we will look at rolling this update back.

  6. Challenge

    Perform a Manual Rollback

    Note: Performing a manual rollback, in this case, is the same as performing an in-place deployment and will follow the same process. There are other options for rolling back code when multiple deployments have been made from the same deployment group. In that case, you can ask CodeDeploy to roll back to the last known good state. In this lab, however, we have only deployed once per deployment group, and the error in the code is not visible to CodeDeploy, as it's a wording issue on the site.

    Create a CodeDeploy Deployment Group

    1. Navigate to CodeDeploy.
    2. Select Applications from the left-hand menu, then select demo-app from the list of applications.
    3. From the CodeDeploy applications details page, select Create deployment group.
    4. For the Deployment group name, enter "quick-fix".
    5. For Service role, select the role created with this lab (the only option).
    6. For Deployment type, select In-place.
    7. For Environment configuration, select Amazon EC2 Auto Scaling groups.
    8. From the dropdown box, select Auto Scaling group demo-blue-green-, which should be the only option.
    9. Scroll down to Load balancer, select Classic Load Balancer, and from the dropdown list select la-lab (the only option).
    10. Select Create deployment group.

    Create a CodeDeploy Deployment

    1. From the CodeDeploy deployment group details page, select Create deployment.
    2. Ensure the Deployment group selected is quick-fix.
    3. Ensure the Revision type selected is My application is stored in Amazon S3.
    4. For Revision location, enter the path of the SampleApp_Linux.zip object in your code bucket. For example: s3://code-bucket-123/SampleApp_Linux.zip.
    5. Scroll to Additional deployment behavior settings and under Content options, select Overwrite the content.
    6. Select Create deployment.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans