How to Revolutionize Your Code Collaboration with AWS CodeCommit
How to use AWS CodeCommit for creating a repository and uploading files.
What is AWS CodeCommit?
AWS CodeCommit is a fully managed source control service provided by Amazon Web Services (AWS). It is designed to allow developers to securely store and manage code repositories in the cloud. CodeCommit, a popular distributed version control system, is built on top of Git and offers features such as branch management, pull requests, and code reviews. It also integrates with other AWS services, such as AWS CodeBuild and AWS CodePipeline, to help automate the software delivery process. CodeCommit allows developers to collaborate on code, track changes, and easily and securely deploy code changes from a single platform.
Let's start with creating a repository in the AWS console. Open your console and search for CodeCommit in the search box on the top left-hand side open the page you will able to see the below page in the image click on create repo as shown below
After this, give a name to your repo and add a small description (optional). Click on create button and you will be done with your repository creation now below page will occur, let’s see what is there.
Here, you can see there is a warning prompt let me tell you more detail about this.
By default, if you are login with your root account then you won't able to SSH this repo. So you have to create an IAM user and add a role to it, So the user can perform this task and always remember about the Least Privilege Principle.
Now go, to the IAM section and create a user with the name you want and remember to download the password. Now you will able to see the below page.
Look into the picture I have marked the name and security credentials box. Click on that tab and scroll down below to see the tab name HTTP git credentials for AWS CodeCommit as shown in the below picture.
Now generate credentials and remember to download and save the user id and passwords.
Let's permit our users to access this CodeCommit and use it for this task. For this, we will go back to our IAM user and scroll down a little bit and click on add permission to attach a policy to your user. Refer to the below image.
Now we age ready for the action, Copy the HTTP path of the repository and we will try to clone it in our system.
Now open VS code on your local device and try to clone it using your HTTP credentials. Before that create a file as shown below.
Open the folder in the terminal to perform the git process and type the below command with your copied https link to clone the repo.
git clone https://git-codecommit.ap-south-1.amazonaws.com/v1/repos.Demo-app
If you get an error in cloning then remember to enter the user id and password to log into your CodeCommit repository. After complete cloning refers to the below image.
As we know that this repo is empty so we will add an HTML file to it and push it to the AWS CodeCommit repository.
Create one index.html file and insert some data or page layout to it as shown below.
git add .
git commit -m "sample file added."
git push origin master
Use the above command to push with the appropriate status you want as I have written a sample file added you can update.
Now let’s, check in the console whether our file is uploaded or not.
Boom, it's present in the repository.
Finally, You have successfully done this tutorial.
So you can follow me for more Blogs on AWS and learn the basics of AWS with me in live practicals and real error-solving methods with the latest updates.
If you like it then follow me on GitHub and want to reach out to me then email me, I will share my further contact:- aniketsharma8800@gmail.com
Thank you for reading,
All the best.