CI-CD on AWS — Part 1

Achintha Bandaranaike
6 min readJul 2, 2023

--

CI/CD is a software development methodology that combines continuous integration and continuous deployment practices. It involves integrating code changes into a shared repository and running automated tests to ensure code quality. CD automates the deployment process, delivering applications to various environments such as development, staging, and production, with minimal manual intervention.

DevOps Cycle

What is Continuous Integration(CI) and Continuous Delivery(CD)?

Continuous Integration and Continuous Deployment (CI/CD) is a software development practice that aims to automate the process of integrating code changes, testing them, and deploying them to production environments. CI focuses on frequently merging code changes into a shared repository, while CD automates the process of deploying applications to various environments.

Why CI/CD?

CI/CD offers several benefits to software development teams. It enables faster release cycles, reduces manual errors, improves collaboration among team members, and increases overall efficiency. By automating build, test, and deployment processes, CI/CD helps teams deliver software more reliably and quickly, ultimately leading to higher customer satisfaction.

Benefits of using CI/CD:

CI/CD offers numerous benefits to software development teams. It facilitates faster time-to-market by enabling rapid delivery of features and bug fixes. The continuous feedback loop achieved through frequent integration and automated testing helps identify issues early in the development cycle, ensuring higher software quality. Additionally, CI/CD promotes collaboration among development, operations, and testing teams, fostering a culture of shared responsibility. Furthermore, the scalability and flexibility of AWS’s infrastructure allow CI/CD pipelines to accommodate growing user bases and handle complex deployments.

Example CI/CD Tools:

There are various tools available for CI and CD. Some popular examples of continuous integration tools include

· Jenkins

· Travis CI

· CircleCI

· AWS CodeBuild

These tools automate the build, test, and integration processes. For continuous deployment, tools like

· AWS CodeDeploy,

· Octopus Deploy,

· Azure DevOps

· GitLab CI/CD

Ensuring the automated and efficient deployment of applications to different environments.

CI/CD Lifecycle:

The CI/CD lifecycle consists of several stages. Developers commit code changes to a version control system, triggering the CI pipeline. The CI pipeline builds the application, runs automated tests, and provides feedback on the code quality. Once the code passes all tests, the CD pipeline takes over, deploying the application to different environments. Monitoring tools ensure the health and performance of the deployed application, completing the CI/CD lifecycle.

Introduction to CI-CD on AWS

Welcome to the section on CI-CD on AWS. How to deploy applications automatically? what we want to do is push code and have the code magically deployed in our production environment. This is called CI-CD. In this section, we have learned how CI-CD is done on AWS.

AWS Services in CI-CD:

  • AWS CodeCommit: Storing our code
  • AWS Codepipeline: Automate our pipeline from code to elastic Beanstalk or other places.
  • AWS Codebuild: Building and automatically testing our code.
  • AWS Codedeploy: Deploying our code to ec2 instances(not using Beanstalk) but in other ways.
  • AWS Codestar: This is a way for us to manage software development activities in one place. And that regroups Codecommit, Codepipeline, CodeBuild, and CodeDeploy in one tool.
  • AWS Codeartifact: Store, publish and share software packages
  • AWS Codeguru: Have automated code reviews using machine learning.

Continuous Integration (CI)

That means that developers are going to push the code very often into a central code repository(ex: GitHub, CodeCommit, Bitbucket).

Developers push the code to a code repo and then there’s going to be a test or build server that will check if the code is correct and working as soon as it's pushed into the code repository. So this could be CodeBuild if it's aws or Jenkins.

So the build server is going to fetch a code and test it and then as a developer, we are going to get feedback about the test and checks that have passed/failed. And we get the build and test results, But we have save time.

So with this, we find bugs early and fix them early. because we are testing the code as soon as it is pushed into a code repository. So the developer doesn’t need to test the code on their machine. They can just push the code and wait for the build server to do it while they do some other tasks.

Therefore, the code is going to be delivered faster because it's going to be tested. Thanks to this we are gonna be able to deploy often because as soon as it's tested and ready, we can deploy it.

CI Cycle

Continuous Delivery (CD):

We have application servers of version 1, and we want our code as a developer to be pushed all the way to these application servers. So the way we do it is that we use CD. Any time we push the code onto the repository, it's going to be deployed, if it's tested appropriately onto our application servers.

So the developer pushes the code the code is going to be tested by the build server (This is the CI Part ). And then after the build is passed (it's fully tested) then there's going to be a deployment server. And the deployment server is going to our application onto our application servers. So the version 1 at first and then if we push again a new version of our code into our repo, then we are going to have application server version 2.

With CD, we ensure that deployments happen often and they are very quick.

We shift away from a mentality of let's do one release every 3 months, it's a very long time. Let's automate you know, up to 5 releases a day. Because every time we push the code into the code repo the code is going to be live onto some application servers.

So do CD, we need automated deployment tools such as CodeDeploy which is an AWS service, or Jenkins CD or Spinnaker, or other tools.

CD Cycle

Tech Stack for CICD on AWS:

CI-CD on AWS

We have the code and the code can live in Codecommit or GitHub or Bitbucket or any 3rd party code repository.

Then we have a build phase, the build phase, and the test phase could be done by CodeBuild on AWS. (Competitor to CodeBuild which is open source called Jenkins CI, or any 3rd party CI server will do as well)

Then we go to the deploy phase we can use CodeDeploy and CodeDeploy will seek and deploy to EC2 instances, on-prem servers. Lambda functions and ECS. Or if you wanted to also provision the infrastructure, we could use Elastic Beanstalk as an alternative to Codedeploy for the deployment and the provision of the infrastructure.

And then to orchestrate all these things to define exactly what happens in our CI-CD process then we can orchestrate everything using AWS CodePipeline.

Next Article you will learn deep dive into these services one by one. See you in the next article.

Don’t forget to follow me via medium and leave a 👏

--

--

Achintha Bandaranaike

AWS Community Builder ☁️| Cloud Enthusiast | 3xAWS | 3xAzure | Terraform Certified | 1xGCP