Getting Started with AWS CodeCommit: A Step-by-Step Guide
Arbythecoder
Posted on October 14, 2023
Introduction:
This article is your personal guide to embracing the power of AWS CodeCommit. We will create AWS CodeCommit repository, connect to an Amazon EC2 instance, set up a local Git repository, make significant code changes, and relish the thrill of your first commit. This journey goes beyond step-by-step instructions; it's about equipping you with the skills and insights you need to master the intricacies of contemporary software development.
Task 1: Create an AWS CodeCommit repository
-
Access the AWS Management Console
- To begin, navigate to the AWS Management Console and search for "CodeCommit."
- Select "CodeCommit" to access the service.
-
Create a Repository
- Click on "Create repository" within the CodeCommit service.
- Provide a unique name for your repository, for example, "My-Repo."
- Optionally, add a description like "My first repository."
- Confirm the creation by clicking "Create."
Task 2: Connect to the Amazon EC2 Instance
-
Access the EC2 Instance
- As part of this lab, an EC2 instance has already been provisioned for you.
-
Establish a Console Connection
- Copy the "Ec2InstanceSessionUrl" value from the instructions.
- Open a new web browser tab and paste the URL.
- This will establish a console connection to your EC2 instance.
Task 3: Create a Local Repository Using Git
-
Install Git on EC2 Instance
- Within the EC2 instance terminal session, run the command:
sudo yum install -y git
.
- Within the EC2 instance terminal session, run the command:
-
Configure Git Settings
- Configure the Git credential helper to work with AWS CodeCommit and enable the use of HTTP paths.
-
Clone AWS CodeCommit Repository
- Retrieve the HTTPS URL of your AWS CodeCommit repository from the AWS CodeCommit console.
- Use the
git clone
command to clone the repository to your EC2 instance.
Task 4: Making a Code Change and First Commit to the Repo
-
Navigate to the Repository Directory
- Change to the directory where you cloned the repository using
cd ~/My-Repo
.
- Change to the directory where you cloned the repository using
-
Create Example Files
- Use the
echo
command to create two example files in your local repository.
- Use the
-
View List of Files
- Check the files in the directory using the
ls
command.
- Check the files in the directory using the
-
Stage Changes
- Stage the created files for commit using
git add
.
- Stage the created files for commit using
-
Check Repository Status
- Use
git status
to view the status of your repository and the staged changes.
- Use
-
Commit Changes
- Commit the staged changes with a meaningful message using
git commit -m "Added cat.txt and dog.txt"
.
- Commit the staged changes with a meaningful message using
-
View Commit Details
- To review the details of your commit, execute
git log
.
- To review the details of your commit, execute
Task 5: Push Your First Commit
-
Push Commit to AWS CodeCommit Repository
- Push the commit from your local repository to your AWS CodeCommit repository using
git push -u origin master
.
- Push the commit from your local repository to your AWS CodeCommit repository using
-
View the Repository in CodeCommit Console
- Return to the AWS CodeCommit console in your web browser.
- Refresh the page to see the files you added to your repository.
Conclusion:
Congratulations! By following these steps, you have successfully created a CodeCommit repository, connected to an EC2 instance, established a local Git repository, made code changes, and pushed your first commit. AWS CodeCommit offers a range of features for secure and efficient source code management, making it a valuable addition to your development workflow.
Are you eager to dive even deeper into AWS and continue your learning journey? AWS offers a fantastic opportunity to access free AWS Builder Labs to elevate your DevOps skills. You can explore these labs by visiting the following link: Free AWS Builder Labs.
Posted on October 14, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.