Objective: To implement a CI/CD pipeline using AWS services for automating the deployment of a Spring Boot Application on Amazon ECS with Docker, integrating CodePipeline, CodeBuild and ECR for seamless updates.
Real-time Scenario: Imagine a retail company that has a Spring Boot-based inventory management system. The system is used by several departments and is hosted in containers to ensure scalability. The company wants to reduce the manual intervention required to deploy updates by automating the build and deployment process. By setting up a CI/CD pipeline, developers can push updates to a GitHub repository, automatically triggering a sequence of actions that build, containerize, and deploy the application without downtime. This ensures faster and more reliable system updates, minimizing operational delays.
- AWS CodePipeline
- AWS CodeBuild
- AWS ECR
- AWS ECS
- Docker
- IAM
- Fork the Springboot app project GitHub repository.
- Create Amazon ECR Public Repository.
- Check and update the buildspec.yml and Dockerfile in GitHub Repo.
- Create AWS CodeBuild project to build the source code and push the image to AWS ECR repository.
- Create AWS ECS cluster with Fargate (launch type), Task Definition and Service to deploy & run containerized application.
- Create & configure AWS CodePipeline to trigger on GitHub changes, integrating CodeBuild and ECS for automated deployment.
- Check and monitor the CI/CD pipeline execution in AWS CodePipeline for GitHub repo changes.
Amazon ECR Public Repository with name “springboot”.
modify the buildspec.yml under github repo:
The build logs displayed that the Build completed, Image created and pushed to ECR.
Tail Logs Screesnhot:
Image pushed to ECR Repository, screenshot:
The Services “springboot-task-service-ya4jo0qk” has been created & deployed successfully in Amazon ECS:
CodePipeline got created.
The Execution of all the Stages of CodePipeline was done successfully.
The CodePipeline – Build stage pushed the image to ECR successfully.
The CodePipeline – Deploy stage deployed the latest app image into the ECS under Services >> Task definitions.
copy the Public IP of deployed Application and access it on browser with below URL: http://44.202.24.165:8080/demo/data
do some code changes in the Application GitHub Repository and then will check that due to Repository code changes if the AWS CodePipeline gets triggered:
Just after the code changes done in Github repo, the AWS CodePipeline execution started automatically.
Now copy the Public IP of latest deployed Application and access it on browser with below URL:
http://44.197.191.99:8080/demo/message
Hence, the AWS CodePipeline is correctly created & configured to automate the Build trigger and Deployment of the Application after any changes in GitHub repo. So, finally the Project is complete and the Objective has been met.