Continuous Integration Pipeline on AWS
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:
- AWS Code Commit
- AWS Code Pipeline
- AWS Code Build
- AWS Code Artifact
- AWS S3 Bucket
- 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
Github repo: https://github.com/Shayan-Naeem/vprofile-project
Code Artifact:
We will create a repo on code artifact to store dependencies.
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.
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
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.
AWS SNS Notification:
Create a SNS notification for aws codebuild to get notification for every pipeline that have successfully build, deployed or failed.
CodePipeline:
Finally create the pipeline integrating all the resources that we have created so far. Pipeline will run in the following order:
- Get source
- Test
- Build
- Deploy
In the deploy stage our code artifact will be stored in aws s3 bucket. So, we also have to setup it.
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