Build a simple CI/CD Pipeline on AWS using AWS Code Pipeline.

Sanskruti Patel
5 min readApr 2, 2024

--

Prerequisites:

Have a GitHub repo for your project, if not create a new repo and push your project code to it.

Steps to Build an AWS CI/CD Pipeline

Step 1: Create an S3 bucket

Sign into the AWS management console and search for the S3 service in the search bar. We will put our project code here so that we can host it.

Click on Create bucket.

Give the name to the bucket and select the region you want to create the bucket in.

Uncheck Block all public access, and check the I acknowledge… warning. Doing so will give the public access to the bucket.

Keep everything else as default and click on Create bucket.

After the bucket has been created successfully, click on the bucket. Go under the Properties tab.

Scroll down to Static website hosting and click on edit.

Enable the static website hosting option, and fill up the index and error document fields. Click on Save Changes.

Now go to the Permissions tab.

Scroll down to Bucket Policy and click on Edit. Paste the following code and click on Save changes.

{
"Version": "2012-10-17",
"Id": "Policy1686380413862",
"Statement": [
{
"Sid": "Stmt1686380410884",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}

We are done setting up our S3 bucket. Now let’s move to the next step.

Step 2: Create a GitHub connection

Go to https://console.aws.amazon.com/codesuite/settings/connections. Click on Create connection.

Select GitHub under Select a provider. Enter the connection name and click on Connect to GitHub.

Authorize under the access request page.

Click on Install new app, if you have not already installed AWS Connector for GitHub app. Select the account you want to install the AWS Connector for.

Allow access to the repositories ass per your needs and click on Install.

Now click on Connect.

The connection has now been successfully created.

Step 3: Create AWS CodePipeline

Search for AWS CodePipeline in the navigation bar. Click on Create Pipeline.

Choose a pipeline name. Select New service role, the role name will be automatically created. This IAM role can later be assigned to the developers. Click on Next.

Under the Source provider, select GitHub (Version 2). Select the GitHub connection we had created in the previous step. Select the Repository name and the Branch name to be used.

Ensure the Start the pipeline… has been checked. Now click on Next.

Select AWS CodeBuild under the Build provider. Click on Create Project under Project name.

Under Project creation, name the project.

Under Environment, select the Managed instance, choose the Operating system. Select Standard under the Runtime. Choose the Image and ensure that the Image version is Always use the latest image….

Leave everything else as default and click on Continue to CodePipeline.

You will now be able to see the project you just created under Project name. Click on Next.

For the Deploy provider, select Amazon S3. Select your Bucket. Check the Extract file before deploy option and click on Next.

Review your pipeline and click on Create Pipeline.

The pipeline will be successfully launched in a few minutes.

After all the stages have succeeded, go to the endpoint URL in your S3 bucket. Your website should now be live. If you make any changes in your code (commit and push to GitHub), you’ll be able to see the changes in the CodePipeline, which will be auto-deployed.

Make sure you terminate and clean all your resources so as not to incur any charges.

Feel free to respond.

GitHub: https://github.com/SanskrutiPatel323/

LinkedIn: https://www.linkedin.com/in/sanskruti-patel-4b35a1237/

Thank you!

--

--