With AWS you can build a CI/CD pipeline. In one of my previous posts, I wrote about how to deploy a Spring Boot application on AWS. To create a CI/CD pipeline in AWS you would need to use – Elastic Beanstalk, AWS CodeBuild and AWS CodePipeline.
1. Create a GitHub Repository
The first thing that you need to do is create a GitHub repository for your code. You can create a GitHub account and upload your code.
2. Create build project using AWS CodeBuild
AWS CodeBuild is a fully managed continuous integration service that compiles source code, runs tests, and produces software packages that are ready to deploy. With CodeBuild, you don’t need to provision, manage, and scale your own build servers. CodeBuild scales continuously and processes multiple builds concurrently, so your builds are not left waiting in a queue.
With AWS free tier, you get 100 free build minutes per month.
Go to the CodeBuild console and create a new build project. I used the same SpringBootSwagger project.
Next step is to connect your GitHub account. Once connected, you should see your repositories in the list.
Next you need to setup your environment.
The next thing that you can do is start your build. Also, make sure to have a buildspec.yml file in your project root. Else, your build will fail.
version: 0.2 phases: install: runtime-versions: java: corretto11 pre_build: commands: - echo Nothing to do in the pre_build phase... build: commands: - echo Build started on `date` - mvn install post_build: commands: - echo Build completed on `date` artifacts: files: - target/SpringBootSwagger-0.0.1-SNAPSHOT.jar
Once your build is successful, you can move on to create a pipeline.
3. Create delivery pipeline using AWS CodePipeline
To create a delivery pipeline, you would need to authorize your GitHub repo.
In the build stage, select the build that you had created in the previous step.
In the deploy stage, select Elastic Beanstalk. For this, you need to have an existing application deployed to Elastic Beanstalk.
In the next step, your pipeline should get built successfully.
Once the pipeline is up and running, any changes you make to your code in GitHub will automatically be picked up by CodeBuild and will be deployed on Elastic Beanstalk.
So, that’s it for this article. Thanks for visiting and happy cloud computing.