CI/CD pipeline on AWS — Part-1

Mudit Mathur
4 min readJul 8, 2023

--

TABLE OF CONTENTS
1. Introduction to AWS CodeCommit
1.1 Why CodeCommit?
1.2 How does CodeCommit work?
2. Tasks
2.1 Task 1: Set up a code repository on CodeCommit and clone it on your local.
2.1.1 Generate Git credentials
2.1.2 Set up a code repository on CodeCommit
2.1.3 Clone repository from CodeCommit
2.2 Task 2: Add a new file from local and commit to your local branch. Push the local changes to the CodeCommit repository.
2.2.1 Add a new file from local and commit to your local branch.
2.2.2 Push the local changes to the CodeCommit repository

1. Introduction to AWS CodeCommit

AWS CodeCommit is a version control service provided by Amazon Web Services. It allows you to securely store and manage various assets in the cloud, including source code, documents, and binary files. CodeCommit is designed to support collaborative development workflows and provides a fully managed service hosted by AWS.

1.1 Why CodeCommit?

a. Fully managed service hosted by AWS.
b. Secure code storage.
c. Collaborative coding.
d. Scalable version control projects.
e. Flexible storage for any file.
f. Integration with AWS and third-party services.
g. Smooth migration from other repositories.
h. Familiar with Git tools and workflows.

1.2 How does CodeCommit work?

To create a CodeCommit repository:
a. Use the AWS CLI or CodeCommit console.

To connect your local repository to CodeCommit:
b. Run git clone with the repository name.

To modify files:
a. Use your local repository to add, edit, or delete files.
b. Stage the modified files locally with git add.
c. Commit the files locally using git commit.
d. Push the files to CodeCommit with git push.

To download changes from others:
a. Synchronize the CodeCommit repository with your local repository using git pull.

2. Tasks

2.1 Task 1: Set up a code repository on CodeCommit and clone it on your local.

Prerequisites:

  • An AWS account
  • AWS Command Line Interface (CLI) installed and configured on your local machine

2.1.1 Generate Git credentials

Go to IAM Service > Click on “Users” in the left navigation pane > Create a New User > Checkbox for Provide user access to the AWS Management Console — optional > Select I want to create an IAM user and give password > Click on Next.

In the next step > Click on Attach Policies Directly > Select the policy AWSCodeCommitFullAccess > Click on Create User.

Download the .csv file since this is the only time you can view and download this password.

Open the User you created > Go to the Security Credentials tab > Scroll down to HTTPS Git credentials for AWS CodeCommit > Select Generate Credentials > Download credentials and click on Close.

These are the Git credentials for accessing CodeCommit.

2.1.2 Set up a code repository on CodeCommit

Navigate to CodeCommit > Give your Repository a name > Click Create.

2.1.3 Clone repository from CodeCommit

In the dashboard, click on HTTPS to copy the URL.

At your instance terminal:

#git clone <https>
https://git-codecommit.ap-south-1.amazonaws.com/v1/repos/codecommit-repo

For the prompt, give the credentials you downloaded earlier.

Go to the repo directory you created now using the cd command.

You have created an empty repository in AWS CodeCommit and cloned it to your local.

2.2 Task 2: Add a new file from local and commit to your local branch. Push the local changes to the CodeCommit repository.

2.2.1 Add a new file from local and commit to your local branch.

Create five files using:

touch file{01..05}.txt

Add these files to the staging area, using:

git status
git add .
git status

To add these in the local repositories history:

git commit -m "Commiting the files I created now"

2.2.2 Push the local changes to the CodeCommit repository

Using the following command, push the changes from your local to the CodeCommit repository.

git push origin master

Verify that the files are pushed into the CodeCommit repository.

In the CodeCommit Repository > Repositories > Code.

--

--