AWS LAB

Blue/Green Deployments with Elastic Beanstalk

Lab Details

  1. This lab walks you through the steps to setup Blue/Green deployments with AWS Elastic Beanstalk
  2. You will practice it using AWS Elastic Beanstalk
  3. Duration: 1 hour
  4. AWS Region: US East (N. Virginia) us-east-1

Introduction

AWS Elastic Beanstalk

  1. AWS Elastic Beanstalk is a Platform as a Service(PaaS) offered by Amazon for deploying and scaling web applications
  2. It allows us to use a wide selection of application platforms.
  3. It also enables us to have a variety of application deployment options. 
  4. It enables the developer to concentrate on developing rather than spending time on managing and configuring servers.
  5. It gives us the ability to automatically scale an application up and down based on the application’s specific needs. 

Blue/Green deployments with Elastic Beanstalk

  1. AWS Elastic Beanstalk performs normal deployments in the current production environment. Due to this, the application will be unavailable to users until the update is complete.
  2. This downtime can be avoided by performing a blue/green deployment.
  3. Blue/Green deployments are used to update an application from one version to another version without any downtime.
  4. The blue environment is your existing production environment carrying live traffic.
  5. The Green environment is an identical parallel new environment running a different or updated version of the application.
  6. Deploying of Blue/Green environments such that you can deploy a new version to a separate environment.
  7. Once the deployment is done, we simply route the traffic from the Blue environment to Green environment by swapping their CNAMEs or using Route 53 to slowly shift percentages of traffic over (not included in this lab)
  8. After the routing is complete, if you face any issues in the green environment, Elastic BeanStalk gives us an option to easily roll back to the blue environment.

Advantages

  • Zero downtime while updating the environments and swapping.
  • It’s Easy to roll back to the older version if you face any issues in the new environment.

Tasks

  1. Create an Elastic BeanStalk application.
  2. Create a Blue environment with a PHP application.
  3. Access the Blue environment’s URL and verify whether you get the PHP application page.
  4. Create a Green environment with a Node.js application. 
  5. Access the Green environment’s URL and verify whether you get the Node.js application page.
  6. From the Green environment, initiated a swap of the environment URLs
  7. Verify whether the green environment’s URL is swapped with blue environment’s URL. 
  8. Access the new URL of the green environment and verify whether you are getting the Node.js application page.

Architecture Diagram

Lab Steps

Task 1: Launching Lab Environment

  1. Launch lab environment by clicking on . This will create an AWS environment with the resources required for this lab.
  2. Once your lab environment is created successfully,  will be active. Click on , this will open your AWS Console Account for this lab in a new tab. If you are asked to logout in AWS Management Console page, click on the here link and then click on  again.
  3. If you have logged into other aws accounts in the same browser, after clicking on the , you will be redirected to a page asking you to logout from the other aws account. 

 

Note : If you have completed one lab, make sure to sign out of the AWS account before starting a new lab. If you face any issues, please go through FAQs and Troubleshooting for Labs.

Task 2: Creating an Elastic BeanStalk Application

  1. Click on  and select under the section.
  2. In the Elastic BeanStalk dashboard, click on 
  • Application Name : Enter whizlabs_beanstalk_application
  • Leave the rest as default.
  • Do not choose the Platform also. Click on .
  • Ignore the Error Message and click on Applications on the left menu and Refresh the console.
  • You will see an Application created.

Task 3: Creating Elastic Beanstalk Blue Environment

  1. Once you have created the whizlabs_beanstalk_application you initially have no environments associated with the application.
  1. You need to Create a new environment for the whizlabs_beanstalk_application. To do so, click on 
  2. On the Select Environment Tier page, select the Web server environment and then click on Select.
  1. On the Create a web server environment page (under Environment Information) provide the Environment name as: whizlabs-blue-environment

Note: The environment name should be unique, if you face any errors while providing the name, then provide a different name.

  1. In the platform, under Managed platform choose PHP from the dropdown.
  1. Under the Application Code, select Sample application and then click on .
  1. The environment will take 5 to 10 minutes to provision the resources. Be patient until the environment setup is complete. In the meantime, you can see the resources being provisioned one-by-one
  2. Once the whizlabs-blue-environment is provisioned, you will get a page with Health status as ok and with a URL for the environment.
  1. Click on the URL at the top-right corner to be navigated to the PHP application page, as shown below:

Task 4: Creating Elastic Beanstalk Green Environment

  1. From the Elastic Beanstalk Application dashboard, click on whizlabs_elasticbeanstalk_application at the top and then click on the Create New environment from the dropdown.
  1. Select the Environment Tier page , then select the Web server environment and click on Select
  1. In the Environment information section, provide the Environment name as whizlabs-green-env (Environment name should be unique, if you face any errors while providing the name, provide a different name).
  1. In the platform, under Managed platform choose Node.Js from the dropdown.

  2.  Under the Application Code, select Sample application and then click on .
  1. The environment will take 5 to 10 minutes to provision the resources. Be patient until the environment is provisioned. In the meantime, you can see the resources being provisioned one-by-one.
  2. Once the whizlabs-green-env is set up, you will get a page with Health status as ok and with a URL for the environment.
  1. Click on the URL at the top-right corner to be navigated to the Node.js application page, as shown below:

Task 5: Swapping the URLs from Blue to Green

  1. Now we have two environments namely whizlabs_blue_environment with PHP and whizlabs_green_environment with Node.js
  2. Next we will need to swap the URLs.
  3. In the Elastic BeanStalk application dashboard from whizlabs_green_env, click on Actions and select Swap Environment URLs.
  1. Choose the Environment name as whizlabs-blue-environment from the dropdown in the Select an Environment to Swap section and then click on Swap.
  1. The swap will take a few seconds to complete. You will see the Successfully completed status under Recent Events.
  1. Once the Swap is completed, note that the URL of the whizlabs_green_env note that replaced with that of the whizlabs_blue_environment.
  1. Now Click on the URL (which was the URL for the whizlabs_blue_environment) and notice the content of whizlabs_green_env instead.

NOTE: After swapping the URLs, if the new page contents don’t show up, then clear the browser cache or try to access the URL from a different browser.

Task 6: Validation Test

  1. Once the lab steps are completed, please click on the  button on the right side panel.
  2. This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
  3. Sample output : 

Completion and Conclusion 

  1. You have successfully created an Elastic BeanStalk application.
  2. You have successfully created a Blue environment with a PHP application.
  3. You have successfully accessed the Blue environment’s URL and verified that the content of the URL is a PHP application page .
  4. You have successfully created a Green environment with Node.js application.
  5. You have successfully accessed the Green environment’s URL and verified that the content of the URL is Node.js application page.
  6. From the Green environment, you have successfully initiated a swap of the environment URL.
  7. You have successfully verified that the green environment’s URL is swapped with that of blue environment.
  8. You have successfully accessed the new URL of the green environment and verified that the content of the URL is Node.js application page.

Source: Whizlab.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: