DEV Community

Cover image for Add a CI/CD pipeline to an Amazon S3 bucket

Posted on

Add a CI/CD pipeline to an Amazon S3 bucket


  1. GitHub account & own repository to commit files.
  2. AWS account , access to management console.

This is a beginner friendly hands on exercise to learn the power of CI/CD in the AWS cloud. It will deploy the changes from your repository in GitHub to the S3 bucket which acts as a static website host.

S3 bucket

Create a S3 bucket which has website hosting enabled.

Commit Pipeline

In this pipeline one defines as to what stages the code commit has to go through before it can be deployed.
It has 3 components:
1.Source stage: Define where the code will be picked up from to deploy it in the cloud. One can see a variety of options while specifying the stage. For Github, install the AWS Github connector to connect to your repository.Select the repository which will be the source for the artifacts & the corresponding branch in the repository.

Image description

2.Build stage(optional): You can specify how you want your code to be built using a yaml script. I have skipped this step as my changes are to the index.html file

3.Deployment stage: Either the build stage or deployment stage should be present. This stage also has different options regarding where to deploy the code.

Image description

Commit code to Github :

After the above two steps are completed, make changes to your code in html file which serves as the landing page for your website & commit the file. Voila!!!! Within seconds you can see that the commit pipeline is triggered & your changes are deployed to the S3 bucket mentioned in the deployment stage.

Below is the result of my code change & this hands on lab:

Before commit:

Image description

After commit:

Image description

Top comments (0)