Setting Up Your CI/CD Pipeline on AWS - Part 1 : Introduction to CodeCommit
What is CodeCommit?
CodeCommit is a managed source control service provided by AWS. It allows developers to store, manage, and version their source code and artifacts securely and at scale. Here are some key features of CodeCommit:
Git Support: CodeCommit supports Git, a popular version control system used by developers worldwide.
Integration: It integrates well with other AWS services, making it easier to create a complete CI/CD pipeline.
Collaboration: CodeCommit enables team collaboration through branch and merge workflows.
Security: It provides secure storage and access to your code, along with audit logs and compliance reports.
Scalability: CodeCommit can handle any size repository with high performance.
In summary, CodeCommit is a reliable and efficient way to manage your codebase and is an essential part of setting up a CI/CD pipeline on AWS.
Tasks for Today
Task 1 : Set Up a Code Repository on CodeCommit and Clone It Locally
Let's break down the steps to set up a CodeCommit repository and clone it to your local machine.
Set Up Git Credentials in AWS IAM:
Access AWS Management Console:
Open your web browser and go to the AWS Management Console.
Log in with your AWS credentials.
Navigate to IAM:
- In the AWS Management Console, search for and select IAM (Identity and Access Management).
Create or Select an IAM User:
You can either create a new IAM user or select an existing one.
To create a new user, click on Add user, enter a username, and select Programmatic access.
Attach the AWSCodeCommitFullAccess Policy:
In the Permissions section, click on Attach policies directly.
Search for AWSCodeCommitFullAccess and select it.
Click on Next: Review and then Create user.
Create Access Key:
After creating the user, you will see an option to Create access key. Click on it.
Note down the Access key ID and Secret access key. You will use these credentials to authenticate Git operations.
Create a CodeCommit Repository:
Navigate to CodeCommit:
- In the AWS Management Console, search for and select CodeCommit.
Create a New Repository:
Click on Create repository.
Enter a name for your repository (e.g.,
MyFirstRepo
) and an optional description.Click on Create. Your repository is now ready to use.
Set Up Git Credentials Locally:
Open Terminal or Command Prompt:
- On your local machine, open the terminal (Linux/Mac) or command prompt (Windows).
Configure Git Credentials:
Run the following commands to configure Git to use AWS CodeCommit credentials:
git config --global credential.helper '!aws codecommit credential-helper $@' git config --global credential.UseHttpPath true
Clone the Repository:
Copy Repository URL:
- In the CodeCommit console, select your repository and copy its HTTPS URL.
Clone Repository:
In your terminal, run:
git clone <repository-URL>
Replace
<repository-URL>
with the URL you copied. This command creates a local copy of the repository on your machine.
Task 2: Add a New File Locally and Commit It to Your Branch
Now, let's add a new file to the repository and commit the changes.
Add a New File:
Navigate to Cloned Repository:
Open the terminal and navigate to the directory where you cloned the repository.
cd MyFirstRepo
Create a New File:
Create a file named
hello.txt
and add some content to it.echo "Hello, CodeCommit!" > hello.txt
Commit the Changes:
Add File to Staging Area:
Add the new file to the staging area using the
git add
command. The staging area is where Git prepares files to be committed.git add hello.txt
Commit Changes:
Commit the changes to your local repository. A commit records the changes made to the repository.
git commit -m "Added hello.txt"
Push the Changes to CodeCommit:
Push to Remote Repository:
Push the changes from your local repository to CodeCommit. This updates the remote repository with your local changes.
git push origin main
Replace
main
with the name of your branch if it's different.
Conclusion
Congratulations! You've successfully set up a CodeCommit repository, cloned it locally, and pushed your first changes. CodeCommit is just the beginning. In the coming days, we'll explore how to integrate CodeBuild, CodeDeploy, CodePipeline, and S3 to create a full CI/CD pipeline on AWS.
A CI/CD pipeline automates the process of integrating code changes, building and testing applications, and deploying them to production. This automation helps deliver software more quickly and reliably.
Stay tuned for more exciting tasks and keep learning!
Subscribe to my newsletter
Read articles from Urvish Suhagiya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Urvish Suhagiya
Urvish Suhagiya
Exploring the world of DevOps ๐.