reference deployment

Blue-Green Deployment on AWS

Using AWS CodePipeline for deploying to AWS Elastic Beanstalk environments

This Quick Start automatically deploys a blue-green architecture on AWS using AWS CodePipeline. It creates a continuous integration/continuous deployment (CI/CD) pipeline in about 15 minutes.

When an application is developed and deployed to an AWS Elastic Beanstalk environment, having two separate, but identical, environments—blue and green—increases availability and reduces risk. In this Quick Start architecture, the blue environment is the production environment that normally handles live traffic. The CI/CD pipeline architecture creates a clone (green) of the live Elastic Beanstalk environment (blue). The pipeline then swaps the URLs between the two environments.

While CodePipeline deploys application code to the original environment—and testing and maintenance take place—the temporary clone environment handles the live traffic. Once deployment to the blue environment is successful, and code review and code testing are done, the pipeline again swaps the URLs between the green and blue environments. The blue environment starts serving the live traffic again, and the pipeline terminates the green environment.

 

 

CodePipeline_Logo_153x107

This Quick Start was developed by
AWS solutions architects.

 

  •  What you'll build
  •  How to deploy
  •  Cost and licenses
  •  What you'll build
  • Use this Quick Start to deploy and configure the following environment for blue-green deployment on AWS:

    • A pipeline that is triggered when an Amazon S3 bucket is uploaded with a new version of the application package that is deployed to the AWS Elastic Beanstalk environment.
    • AWS Lambda functions to clone the blue environment as the green environment, to swap the URLs, and to terminate the green environment when deployment and testing for the blue environment are complete.
    • AWS CodeBuild projects to perform the initial URL swap between the blue and green environments and to test the deployment of the blue environment.
    • If an existing Elastic Beanstalk environment and the application where it exists is not provided, this Quick Start creates a sample environment.
    • AWS IAM roles for the Lambda functions, CodeBuild projects, CodePipeline, and service role for the Elastic Beanstalk sample application.
    • Separate Amazon S3 buckets for the CodePipeline Artifact Store, the Lambda Function assets, and the CodeBuild assets. You can have an optional S3 bucket for storing the zip package that contains application code for the Elastic Beanstalk deployment.
  •  How to deploy
  • To build a blue-green architecture on AWS, follow the instructions in the deployment guide. The deployment process includes these steps:

    1. Check the prerequisites.
    2. If you don't already have an AWS account, sign up at https://aws.amazon.com.
    3. (Optional) Make a note of an existing Elastic Beanstalk environment and application. You can skip this step if you want to launch a sample environment and application.
    4. Launch the Quick Start and customize your settings. The deployment takes about 15 minutes.
    5. (Optional) If Git to S3 integration is enabled, configure your Git repository.
    6. Test the deployment.
  •  Cost and licenses
  • You are responsible for the cost of the AWS services used while running this Quick Start reference deployment. There is no additional cost for using the Quick Start.

    This Quick Start launches a pipeline that interacts with the Lambda functions, AWS CodeBuild, Amazon Simple Notification Service (SNS), and Elastic Beanstalk for cost-efficient deployments. Optionally, you can enable the Git Webhooks with AWS Services Quick Start with this Quick Start, for linking your Git Repository to Amazon S3. Git to Amazon S3 provides an Amazon API Gateway endpoint and Lambda functions to handle downloading, zipping, and deploying code to Amazon S3.

    AWS CodePipeline carries a cost for each active pipeline; see AWS CodePipeline pricing. AWS CodeBuild and Amazon SNS use pay-as-you-go pricing; for details, see AWS CodeBuild and Amazon SNS. Depending on your configuration, the Git Webhooks with AWS Services Quick Start may deploy an AWS Key Management Service (AWS KMS) key; for pricing, see AWS Key Management Service pricing. API Gateway, Amazon S3, and Lambda costs vary depending on how often you commit code to your repository. Each commit triggers a request to the Lambda execution in API Gateway; for details, see the pricing pages for API Gateway, Amazon S3, and Lambda.