As you can see in the title, today we are covering the first service of AWS DevOps, which is 'CodeCommit.' I hope you've read the introduction part of this series; if not, please check it out. AWS CodeCommit is similar to other centralized code repositories like GitHub, GitLab, GitBucket, and so on; the only difference is that it's an AWS private repository that you can use. For more information, you can read about it on AWS CodeCommit
So today, we'll learn how to create a repository in CodeCommit, create a user for it, provide necessary permissions to that user using the IAM service, clone that repository into our local machine, make some changes, and push it back to the repository. Additionally, we'll explore how to create branches, merge them in CodeCommit, and cover some other important options. Let's get started!
-1-. Begin by searching for the 'CodeCommit' service. As you know, the first step involves pushing code into the repository.
-2-. Next, navigate to 'Repository,' where we push our code. To do this, click on 'Create Repository.'
Then, provide a name and description for the repository. You'll notice 'CodeGuru,' which is similar to 'SonarQube Scanner' for code scanning. However, at this point, we don't want to proceed directly to 'create repository.'
-3-. You'll encounter a warning indicating that using the root user is not recommended. To address this, let's create another user in 'IAM' to enable the use of services in AWS DevOps. Proceed to 'IAM' now.
-4-. In 'IAM,' navigate to 'Users,' click on 'Add Users,' and provide a name for the user.
-5-. In the 'Set Permissions' window, click 'Next.' On the 'Review' page, you'll notice that we currently have only one permission, which is the ability to change the password. Proceed to click 'Create User.'
-6-. You can save this password, as it is displayed only once, or download the '.csv file.'
-7-. Now that our user is created, click on it. We want to grant permissions for 'CodeCommit,' so first, navigate inside it and then click on 'Security Credentials.'
-8-. Scroll down, and you'll find 'HTTPS Git credentials for AWS CodeCommit.' Click on 'Generate Credentials.' Here, you will see your credentials generated. You can also download them, and with these credentials, you can access.
-9-. Return to the 'CodeCommit' window, click on 'Clone URL,' and choose the 'HTTPS' option. Create a folder, open your preferred code editor (like VS Code), and clone the repository to your local computer.
-10-. While cloning, a pop-up will appear asking you to enter the Git credentials created for 'CodeCommit.' Simply copy and paste them in this window.
-11-. If the cloning process is not working, we might have missed setting up IAM permissions for cloning and committing. Go back to the 'Users' section, select the user, navigate to the 'Permissions' tab. As there is only one permission currently, click on 'Add permission' → 'Attach Policy Directly' → 'AWSCodeCommitPowerUsers.'
-12-. Now, try the process again in 'VS Code.' This time, you should see a 'Clone successful, empty repository' message.
-13-. Next, add an 'index.html' file with some sample text. After making changes, commit and push this code into our repository.
-14-. Navigate to 'CodeCommit' → 'Repository,' and refresh. You should now see our files in the repository.
-15-. This is how you can connect your local machine to AWS CodeCommit using IAM credentials, similar to connecting to GitHub. Now, let's create another branch, push the code, and check the 'Branches' section in CodeCommit to see the newly created 'dev' branch.
-16-. Now, let's merge the changes into 'Master.' Click on the branch, create a pull request, provide a name, create the pull request, merge it using fast-forward, and delete the source branch after merging. Refresh the 'Master' branch to see your changes successfully merged.
-17-. So, this is how you can use the 'CodeCommit' service.
Top comments (0)