CI/CD (Continous Integration/Continous Deployment) plays an important role in application lifecycle management. CI/CD pipelines are repeatable, less prone to errors, and they are self-explanatory – can serve as a documentation of the deployment process.
One of the most common mistakes when setting a new development project is not building a deployment pipeline since the early stage. Even if you are just a team of one developer, it is a very good idea to focus on quality from the very start.
For this reason, in this article, we will focus on the very minimal CI/CD that can be quick and easy to set-up. In our example we will deploy from Github to an AWS account.
AWS CodePipeline is an excellent choice for CI/CD if your infrastructure is on Amazon AWS.
Usually, CI/CD pipelines consist of the following stages:
- source – take latest changes from source control
- package management – install required packages
- unit test – run unit tests
- verify – run smoke tests
We will take a look at one straightforward CI/CD pipeline – static website hosted on S3, and we will use a yarn package manager. Also, we will assume that the source code is hosted on GitHub.
We, at TyphoonX usually start Terraform IaC projects with a provider setup and variables definition:
Terraform provider definition
Variables used trough the project
Next, we need to create an AWS CodePipeline script with the following stages:
- Source – we will use GitHub source control
- Build – simple buildspec
- Deploy – copy artifacts to AWS S3 Bucket
First we need to create an AWS CodeBuild project:
AWS CodeBuild script
Next we will create pipeline and use CodeBuild project that we’ve just created.
AWS CodePipeline script
Finally, to automate everything, we need to connect source control with the pipeline and trigger pipeline release on code changes/commits. In order to do so, we will create hooks that will trigger pipeline release.
Webhooks for AWS and GitHub, using random secret key:
In a more advanced setup, additional stages and configurations can be added, like: packaging and security check, integration tests, smoke tests, notifications, approvals, Pull Requests, etc.
I work on TyphoonX – a cloud-native platform that automates application lifecycle management in cloud environments, focused on AWS.