CI and CD stand for continuous integration and continuous delivery/continuous deployment. In other words, CI is a contemporary method of software development where incremental code changes are reliably and regularly produced. Code updates that are merged into the repository are made reliable by automated build-and-test procedures that are sparked by CI. Then, the code is swiftly and efficiently deployed as part of the CD process. The CI/CD pipeline, as used in the software industry, is the automation that enables developers to consistently and quickly transfer incremental code changes from their desktops to Git repositories and then finally into the production environment with specific changes applied to it. 

Continuous integration (CI) is a technique where developers check and make minor changes to their code and promptly deploy it effortlessly. This process is automated because of the size of the requirements and the number of steps needed to complete it, allowing teams to design, test, and bundle their applications in a dependable and repeatable manner. 

CI streamlines code updates, giving developers more time to make changes and contribute to better products.

The automated transmission of finished code to contexts like testing and development when get integrated with the actual environment stage is known as continuous delivery (CD). Code delivery to various contexts is made automated and standardized via CD.

The next phase after continuous delivery is continuous deployment. There are numerous production deployments because every modification that passes the automated tests is seamlessly put into production. Most businesses that are not bound by regulatory or other limitations should aim toward continuous deployment.

Why the Continuous Integration & Continuous Deployment has became so popular nowadays?

CI/CD allows organizations to ship software quickly and efficiently to the Internet community of their product. In addition to continuously releasing code into production and assuring an ongoing flow of new features and bug fixes via the most effective delivery method, CI/CD provides an efficient procedure for bringing goods to market more quickly than ever. 

It significantly reduces the product’s release time and saves the company’s resources time to dive into overheads. 

Implementation of AWS Cloud Native Codepipeline CI/CD Automation:

We’ll be using the GitHub repository & AWS codepipeline to deploy a containerized application on the Amazon Elastic Container Service(ECS) through the CICD mechanism. 

Prerequisites:

Let’s get started:

First, create an ECR repository to push a docker image in it.

Output: 

The ECR repository ‘test-repo’ is ready.

Now, create an ECS task definition where the ECR repo URL will be integrated.

Add the environment variables(optional).

  App environment such as ‘AWS Fargate Serverless’.

  Operating systems as ‘Linux/x86_64’.

  Set the task size: 1 vCPU & 2GB memory

Now, Create the ECS cluster to deploy the ECS service on it.

Output:

Then, create an ECS service to deploy the task definition through it.

Deployment configurations:

Output:

Now, the deployment infrastructure is ready. We’ll be moving toward the CI/CD implementation to automate deployment configurations through AWS CodePipeline.

Output:

(Note: As the source provider ‘version 1’ is not recommended nowadays but we’ll continue the CICD with it.)

As we are using a containerized application, allow the following checkbox to build the docker images:

Output:

Possible buildspec:

version: 0.2

env:

  variables:

    IMAGE_TAG: "latest"

   # key: "value"

phases:

  pre_build:

    commands:

      - echo $ENVIRONMENT

      - echo Entered the pre_build phase...

      - echo logging in docker hub

      - docker login --username $DOCKERHUB_USERNAME --password $DOCKERHUB_PASSWORD

      - echo Logging in to Amazon ECR...

      - ACCOUNT_ID=${account_id}

      - REPOSITORY_URI=${repository_url}

      - aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com

  build:

    commands:

      - echo Build started on `date`

      - echo Building the Docker image as $ENVIRONMENT environment...

      - docker build --build-arg ENVIRONMENT=$ENVIRONMENT -t $REPOSITORY_URI:$IMAGE_TAG .

  post_build:

    commands:

      - echo Build completed on `date`

      - echo Pushing the Docker images...

      - docker push $REPOSITORY_URI:$IMAGE_TAG

      - echo Writing image definitions file...

      - cd $CODEBUILD_SRC_DIR

      - pwd

      - printf '[{"name":"${container_name}","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json

artifacts:

  files: imagedefinitions.json

Output:

Now, the Codebuild project is ready.

 And click on the ‘create pipeline’.

After the creation of Codepipeline, when we hit the ‘release change’ button to trigger the pipeline manually. It will initiate the automated CICD process.

Note: Whereas, the pipeline will also automatically be triggered whenever there’s a change push into the attached GitHub repo through Webhooks configuration. 

Output: 

The CodePipeline’s Source stage is passed successfully. And the Build stage is just initiated:

Output:

Output:

Multiple use cases can be integrated with the advanced CICD pipeline such as security checks, Role-Based Access Control, or automated testing integration with it. Utmost every popular cloud services provider allows us to work with it. It is needed and becoming an industry standard to implement deployment automation accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *