CI/CD for applications on Amazon EC2, Amazon Elastic Beanstalk

AWS provides a bunch of services to create your application's Continuous Integration and Continuous Deployment pipelines natively on AWS. There are also many popular tools, such as Jenkins, Bamboo, TeamCity, and Git, that can either be independently set up on AWS or even integrated with the CI/CD services that AWS offers. As a whole, there are plenty of options and users can pick and choose the right ones as per their needs:

Capability

AWS Service

Other tools

Source code repository, version control, branching, tagging, and so on

AWS CodeCommit

Git, Apache Subversion (SVN), Mercurial

Compiles source code and produces software packages that are ready to deploy

AWS CodeBuild

Jenkins, CloudBees, Solano CI, TeamCity

Tests automation covering functionality, security, performance, or compliance

No direct AWS services, but AWS CodeBuild can integrate with various testing tools

Apica, Blazemeter, Runscope, Ghost Inspector

Automated code deployments to any instance

AWS CodeDeploy

XebiaLabs

 

Apart from the preceding services, AWS also offers two other services that help in DevOps-related implementations:

AWS CodePipeline: This helps you fully model and automate your software release processes in the form of pipelines. A pipeline defines your release process workflow, and describes how a new code change progresses through your release process. A pipeline comprises a series of stages (for example, build, test, and deploy), which act as logical divisions in your workflow.

The following is a sample CodePipeline based CI/CD pipeline and uses various other services like AWS CodeCommit, AWS CodeBuild, AWS Lambda, Amazon SNS, and AWS CodeDeploy to orchestrate the entire process. As CodePipeline integrates with AWS Lambda, it also gives you additional options to customize actions and workflows in line with your CI/CD process requirements:

A sample CodePipeline based CI/CD pipeline

Using the previously mentioned CI/CD process, you can either have in-place updates, which is code being deployed to the same EC2 instances, or have a new fleet of instances to perform Blue/Green deployment, in which Blue is the current environment and Green is the new environment with the latest code changes. The concept of Blue/Green deployments is also based on the cloud best practices of immutable infrastructure, wherein your instances and environment are totally replaced rather than being updated in case of any new configuration or code release. This is analogous to the immutable variables in many programming constructs where you instantiate them once and they can never be updated, which makes the process of any changes easy and consistent, avoiding any conflicts, as it's always a new variable or instance.

The main benefits of performing Blue/Green deployments are as follows:

  • You don't touch an existing environment, thereby making the application updates less risky
  • You can gradually roll over to the new (Green) environment and can easily roll back over to the previous (Blue) deployment if there are any issues
  • You treat the infrastructure as code, baking the entire process of creating Blue/Green deployments within your application deployment scripts and processes

The following is a sample Blue/Green deployment using AWS CodeDeploy, where you replace an autoscaled set of EC2 instances behind an ELB (Blue environment), to a new set of autoscaled instances (Green environment). You can find more details on the process in the AWS documentation at http://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html#welcome-deployment-overview-blue-green:

In order to quickly use and integrate the various AWS DevOps oriented services, AWS has another service called AWS CodeStar. This service provides a unified user interface and a project management dashboard, including an integrated issue tracking capability, enabling you to easily manage your software development activities in one place. This service also offers various templates of sample applications that can deployed to Amazon EC2, AWS Elastic Beanstalk, and AWS Lambda, and managed using various DevOps services. The following is a screenshot of the AWS CodeStar dashboard for one of the provided sample applications:

AWS CodeStar dashboard
..................Content has been hidden....................

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