The Ops Community ⚙️

Cover image for Continuous Delivery with AWS CodePipeline
Jatin Mehrotra
Jatin Mehrotra

Posted on

Continuous Delivery with AWS CodePipeline

Continuous Delivery(CD) is a pillar of modern application development which is often combined with Continuous Integration (CI). It is a DevOps method/principle which ensures code changes by developers are automatically prepared for release to production.

This blog explains the Continuous Delivery concept for a person who is just starting with DevOps and wants to understand the need for CI/CD.

What is Continuous Delivery?

When a code/feature is written and pushed to a repository ( GitHub, CodeCommit), it is automatically built and tested to ensure changes haven't broken the app and a deployable artefact is produced ( this process is Continuous Integration CI).

Here comes our topic for the blog. Continuous Delivery comes right after CI. Now the code is tested and not broken it's time to deploy it to either the dev/testing environment or production environment.CD ensures that code is automatically deployed after the successful CI phase.

Note:- Often people use Continuous Deployment as colloquial to CD, let's not get stuck to semantics. The major difference between continuous delivery and continuous deployment is with continuous delivery, is the presence of a manual approval to update to production. With continuous deployment, production happens automatically without explicit approval.

In this blog we are going to build a pipeline with AWS CodePipeline which demonstrates the concept of continuous delivery(CD).

Architecture

aws codepipeline architecture

What is AWS CodePipeline?

  • Fully managed continuous delivery service that helps you create, and automate release pipelines.
  • CodePipeline allows adding different stages which can be used to test, build and deploy every time there is a code change, based on the release model you define.
  • You can easily integrate AWS CodePipeline with third-party services such as GitHub.
  • With AWS CodePipeline, you only pay for what you use. There are no upfront fees or long-term commitments.

Creating a simple pipeline

For this blog, I am trying to keep it as beginner-friendly as I can and focus more on the Continuous Delivery concept.

  • Create a sample elastic beanstalk nodejs application refer docs
  • This results in a sample web page which is green in colour.

  • Note:- Create a separate environment for the same sample application and name it sample-app-prod-env

Green image elastic beanstalk

  • Create a code commit repository and upload index.html file present in this repository

Creating code commit repo with index.html

  • Edit index.html and change it to blue.
.textColumn {
        position: absolute;
        top: 0px;
        right: 50%;
        bottom: 0px;
        left: 0px;
        text-align: right;
        padding-top: 11em;
        background-color: blue;
      }
Enter fullscreen mode Exit fullscreen mode
  • Create a pipeline using code pipeline from AWS console.

creating codepipeline

  • Configure the source of the pipeline as the code commit repository with the branch name and repository name.

  • Configure the deploy stage for the pipeline as the elastic beanstalk and the sample application created earlier.

  • The moment the pipeline is created, it triggers the pipeline and deploys automatically the index.html contents to the elastic beanstalk application.

Code pipeline flow

codepipeline triggers blue color deployment

  • Code Pipeline also allows deploying to many stages for example one for dev env, another for production stage.

  • Code Pipeline also allows adding manual approvals when automatic deployment for the production environment.

add action for manual approval

  • Here we are adding to a sequential action group one for manual approval and another for deployment to the elastic beanstalk production environment.

add manual approval action

deploy to prod env

  • Once manual approval is added, edit the code in code commit and change the colour to red.

  • the pipeline automatically deploys to the production environment which is verified by a change in the colour of the prod to red.

code pipeline manual approval

prod env tuned to red

From AWS DevOps Perspective

  • Codepipeline orchestrates the entire CI/CD flow by allowing to add of build, test and deploy stages.
  • Codepipeline stores results of each stage as artefacts in the s3 bucket, so that the next stage knows how to proceed.
  • Codepipleine requires an IAM service role with appropriate IAM policies to perform the action.
  • Codepipline changes can be monitored using cloud watch events which can be used to create alarm and slack notifications.

Top comments (0)