Skip to main content

Blue/Green Deployments with AWS Elastic Beanstalk

Hands-On Lab

 

Photo of Craig Arcuri

Craig Arcuri

AWS Training Architect II in Content

Length

00:30:00

Difficulty

Intermediate

Blue/Green Deployments provide a deployment method with the advantages of greatly reducing downtime and ease of rollback. There are multiple ways to perform Blue/Green Deployments, but the most common involves using Route 53 to switch the DNS record from the Blue environment to the Green environment. Using Elastic Beanstalk has the advantage of performing the DNS switch behind the scenes for the user who simply has to select 'swap urls'. A second environment can be created in Elastic Beanstalk by selecting 'Clone Environment'.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Blue/Green Deployments with AWS Elastic Beanstalk

Introduction

In this hands-on lab, we're going to focus on the mechanics of creating an Elastic Beanstalk environment, cloning it (or creating a second Elastic Beanstalk environment), and then swapping the environment URLs — thus successfully achieving a blue/green deployment.

Log in to the AWS environment with the cloud_user credentials provided on the lab page. Once inside the AWS account, make sure you are using us-east-1 (N. Virginia) as the selected region.

Create an Elastic Beanstalk Application

  1. Navigate to Elastic Beanstalk.
  2. Click Create New Application.
  3. Set the Application Name (e.g., "BlueApp") and Description (e.g., "Blue App for Blue Green Deployment"), and click Create.

Create Elastic Beanstalk Environment

  1. No environments currently exist for this application. Click Create one now.
  2. On the Select environment tier page, make sure Web server environment is selected, and click Select.
  3. Under Base configuration, for the Platform, select Preconfigured platform and choose Node.js from the dropdown.
  4. For Application code, select Sample application.
  5. Click Configure more options.
  6. On the Configure [APP]-env page, in the Network box, click Modify.
  7. On the Modify network page, select the provided VPC in the dropdown.
  8. Check the box to Assign a public IP address to the Amazon EC2 instances in your environment.
  9. Check the box next to all three availability zones.
  10. Click Save and then Create environment.
  11. Once the new environment is created, open the URL listed at the top in a new browser tab to check it out.

Clone Elastic Beanstalk Environment

  1. Back in the application dashboard, click Actions and select Clone Environment.
  2. On the Clone Environment page, under New Environment, add "-green" to the end of the Environment name and Environment URL.
  3. Leave the other defaults, and click Clone.

Swap Environment URLs, Part 1

  1. Once the new environment is created, click Actions and select Swap Environment URLs.
  2. Click Swap.
  3. Under Recent Events, we'll see a message that the operation was aborted because the environments are identical.

Create New Elastic Beanstalk Environment

  1. Click BlueApp at the top, and select Create New Environment.
  2. Select Web server environment.
  3. For Environment name, give it a different name (e.g., "Blueapp-env-green2").
  4. Under Base configuration, choose Preconfigured platform and select PHP.
  5. Click Configure more options.
  6. On the Configure [APP]-env page, in the Network box, click Modify.
  7. On the Modify network page, select the provided VPC in the dropdown.
  8. Check the box to Assign a public IP address to the Amazon EC2 instances in your environment.
  9. Check the box next to all three availability zones.
  10. Click Save and then Create environment.
  11. Once the new environment is created, head to the URL to check it out. We should see our new PHP application is running.

Swap Environment URLs, Part 2

  1. Back in the application dashboard, click Actions and select Swap Environment URLs.
  2. Under Select an Environment to Swap, select the very first environment we created from the Environment name dropdown.
  3. Click Swap.
  4. Under Recent Events, we should see it successfully completed swapping the environments.
  5. Now, head to the URL (which should look like our original URL from the first environment we created), and we should see the PHP application instead of the Node.js application.

Conclusion

Congratulations on completing this lab!