Continuous Integration Pipeline on AWS

Shayan Naeem
4 min readJul 16, 2023

--

Automated CI Pipeline Architecture

Abstract:

This project consist of some AWS services for the integration of fully automated CI pipeline of java application on AWS. If Developer push the code to the AWS Code Commit triggers will be generated and thus start continuous integration from staging area to deployment.

Services used:

  1. AWS Code Commit
  2. AWS Code Pipeline
  3. AWS Code Build
  4. AWS Code Artifact
  5. AWS S3 Bucket
  6. Sonar Cloud Code Analysis

Working:

CodeCommit:

First of all, we will pull the code from the github repo and setup the repo on AWS CodeCommit.

We can create our local setup on machine by using the git bash. Make sure to connect your local machine to AWS CodeCommit. Our branch for this project will be “ci-aws”. Use this branch & push it to aws codecommit.

Make sure to have downloaded aws cli on your system

choco install awscli -y
Git Bash setup on local machine

Github repo: https://github.com/Shayan-Naeem/vprofile-project

AWS CodeCommit Source

Code Artifact:

We will create a repo on code artifact to store dependencies.

AWS code artifact repo source

Create a local setup by generating the token to connect with code artifact.

Follow the above instructions to connect with your system

Change the URL from the setting.xml file as well as pom.xml file. You can get your URL form the above snap. However files are updated at my github repo. https://github.com/Shayan-Naeem/vprofile-project

Sonar Cloud setup:

Sonar cloud is used for code analysis to determin bugs, erros & quality assurance of the project.

Go to https://sonarcloud.io & create your account if you don’t have it. Create your project. Fill all the necessary details & also generate the token by going the > My account > Security to connect with aws.

Sonar Cloud Project Dashboard

Parameter Store for Sonar Cloud:

We will use aws systems manager for storing the parameters. Store the following the details by fetching the values from sonar cloud & code artifact.

CodeBuild for SonarCode Analysis:

Setup the code build test job for sonar cloud analysis to test the java application code. Write the buildspec.yaml file in the build job. You can find it in repo. Customize all the parameters that defined in the sonar cloud or systems managers in the buildspec.yaml file.

We can setup the customize parameters at sonarcloud Quality Gate. I have setup quality gate that if code have more than 10 bugs then it will fail the job. See

Quality Gate at sonar cloud
More than 10 bugs
Build for sonar code analysis failed

Create Build for Code Artifact:

Setup the build for code artifact. Fill all the necessary information & copy the buildspec.yaml file. Change the values as per your defined parameters.

Build for code artifact

AWS SNS Notification:

Create a SNS notification for aws codebuild to get notification for every pipeline that have successfully build, deployed or failed.

AWS SNS notification for code pipeline

CodePipeline:

Finally create the pipeline integrating all the resources that we have created so far. Pipeline will run in the following order:

  1. Get source
  2. Test
  3. Build
  4. Deploy

In the deploy stage our code artifact will be stored in aws s3 bucket. So, we also have to setup it.

S3 bucket for storing code artifact
CI Pipeline Source + Test
CI Pipeline Build + Deploy

Congratulations! We have successfully integrated fully automated continuous integration pipeline on AWS.

Conclusion:

Developer now can now push the code to the aws code commit & it can easily be integrated through this automated pipeline using aws services

If you find this project insightful. Please follow me on linkedin as well as on medium. Don’t hesitate to give your valuable feedback in the comments section. I will be more than happy to hear from you.

Linkedin: https://www.linkedin.com/in/iamshayannaeem/

Medium: medium.com/@iamshayannaeem

#devops #aws #github #linux #docker #kubernetes #jenkins #cicdpipeline

--

--