top of page

Create an automated software release pipeline (CI/CD pipeline) using AWS CodePipeline and CodeCommit

Updated: Nov 28, 2021

Create an automated software release pipeline (CI/CD pipeline) using AWS CodePipeline and CodeCommit.


Tutorial Objectives:

1. Learn to deploy your code every time there is a code change using AWS CodePipeline.

2. Learn to use an Amazon CodeCommit as a source code repository.

3. Learn to automate the software release process by continuous deployment of application code revisions.


Step 1: Create your Elastic Beanstalk Application

Log on to your AWS Management Console and search for Elastic Beanstalk.

Once the page opens, click on Create Application and mention the rest as follows:

· Application Name: CodeCommitCICD

· Platform: PHP

Upload your own code by downloading the CI_CD.zip file from this link here.

Note: In the zip file, you will find 3 folders within it. Make sure you upload ‘V1’ (Version 1) first.

Now, click on Create Application. You will find version-1 of the application deployed.


Step 2: Create a CodeCommit Repository

Open AWS Management Console on another tab and search for CodeCommit.

Fill in the Repository name as CICDRepo and by leaving the rest as default, click on Create.

Go ahead and Copy the command to clone your repository.


Step 3: Now, open your AWS management console in another new tab and navigate to Cloud9.

Click on Create environment

Give a name to your Environment, We’ll call it CodeCommit_Playground

Once the environment is up and running paste the previously copied git clone command in the terminal.

For remote accessing the CodeCommit bucket we need to provide our user’s http credentials to the AWS via the terminal. For that, run the following commands.

cd CICDRepo/
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

Now, we need to specify the user who is going to commit the changes in our CodeCommit repository.

For that, we need to execute the following commands to specify the user.

git config --global user.name "<Your Name>"
git config --global user.email <your.email@email.com>

Now, In the left navigation pane, where you can see the folder structure of your environment click on your repository name. For now, it is CICDRepo.

This will ensure that when we upload our Version 2 files, they will be uploaded in the folder of the repository.

From the Welcome tab click on Upload Files…

When the Upload Files pop-up appears make sure the path specifies Upload to folder: /CICDRepo and click on Select Files to upload the version 2 files of our Web Application

From the extracted CodeCommit folder, Go into the Version 2 folder and select the following files to upload:

appspec.yml

index.html cpp img.png


Click on Open and these files will be uploaded to our repository folder.


As you can see in the left folder structure pane, all our files are uploaded inside our CICDRepo folder

Run the following commands to push these files to our CodeCommit repository.

git add .
git commit -m "Version 2 of the Web Application"
git push

git add . : This command will add all the uploaded files to the staging area to commit the change.

git commit -m “Version 2 of the Web Application” : This command will commit our new changes with the message “Version 2 of the Web Application”.

git push : This command will push all these changes to the master branch of our CodeCommit repository.

Now, go back to your CodeCommit tab and refresh the page. And you’ll be able to see the new Version 2 files are uploaded inside the CodeCommit repository


Step 4: Create a Code Pipeline

In the AWS Management Console, search for Code Pipeline and open it.

Click on Create pipeline and do as follows.

· Pipeline Name: CodeCommitCICD

· Service Role: New Service role

Keep the rest as default and click on next.

Give the source provider as AWS CodeCommit.

Choose the Repository name as CICDRepo and branch name as master.

Keep the rest as default and click on Next.

Skip the build stage.

Under deployment provider, choose AWS Elastic Beanstalk and choose the correct application and environment name.

Click on Next.

Confirm the settings and click on Create Pipeline.

Now wait for the Source and Deploy section to complete its action.

Once this is done, go back to the page where our application is hosted and refresh the page.

You will find that the Version-2 has been deployed.

Now to deploy Version 3, repeat Step 3.

Simultaneously, the CodePipeline section will be updated automatically for Version 3.

Once this is done, go back to the page where our application is hosted and refresh the page.

You will find that the Version-3 has been deployed.

Note: If you no longer need the resources, delete code pipeline, codecommit repository as well as Elastic Beanstalk Application and Environment.


Was this document helpful? How can we make this document better? Please provide your insights. You can download PDF version for reference.

CICD Pipeline With CodeCommit
.pdf
Download PDF • 546KB

We provide the best AWS training from Pune, India.

For aws certification contact us now.

164 views5 comments

5 Comments


Aditya Joshi
Aditya Joshi
Oct 03, 2023

Good blog

Like

Prajval Suryaji
Prajval Suryaji
Sep 28, 2023

good

Like

Really helpful blog for understanding AWS Code Pipeline and CodeCommit.

Like

Parth Rewoo
Parth Rewoo
Aug 13, 2022

Very informative blog!!

Like

Vaibhav Deshpande
Vaibhav Deshpande
Apr 15, 2022

This blogs are so good


Like
bottom of page