Step 0: Setup Required for Access to CodeCommit
Before anything, you just need to produce an IAM user for CodeCommit and assemble your native pc for access. One should install the AWS interface to enjoy the AWS managed services for CodeCommit and one can do most CodeCommit tasks without it as well. When you work with Git at the command line or terminal, the AWS interface offers flexibility.
In case, suppose you are already done with the set up for CodeCommit, you can directly jump to Step 1.
How to create and configure an IAM user for accessing CodeCommit?
Please feel free to consider below-mentioned information!
- Create an AWS account.
- You should create an IAM user for your AWS account and ensure the presence of an access key ID and a secret access key associated with that IAM user.
- Next, you should sign in to the AWS Management Console and should open the IAM console.
- Within the IAM console, open the navigation pane, select Users, and then, should select the desired IAM user to configure for CodeCommit access.
- For the Permissions tab, you should select Add Permissions.
- Within the Grant permissions, you should select Attach existing policies directly.
- From the list of policies, select desired managed policy for CodeCommit access.
After the selection of the desired policy, choose Review to evaluate the list of policies that are attached to the IAM user. If the list is correct, then you should select Add permissions.
How to install and configure the AWS CLI?
- The first step is to download and install the AWS interface on your pc.
- You should run the command to verify the CodeCommit commands for the AWS interface installation.
- The command must return a list of CodeCommit commands.
- You should configure the AWS interface with the configure command.
- When prompted, you should state the AWS access key and AWS secret access key of the IAM user to use with CodeCommit. And, you should ensure to specify the AWS Region where the repository exists.
- You should reconfigure the AWS interface with the default Region name for connecting to a repository or a resource in the other AWS Region. Some of the supported default Region names for CodeCommit are:
Now, you need to install Git.
For Linux, macOS, or Unix:
You need to install Git on your pc to work with files, commits, and other information in CodeCommit repositories that support Git versions 1.7.9 and later.
You must install Git on your pc to work with files, commits, and other information in CodeCommit repositories that support Git versions 1.7.9 and later.
You must configure Git credentials for CodeCommit that supports both HTTPS and SSH authentication for complete setup. To access CodeCommit, you should use SSH key pair.
Step 1: Create a CodeCommit Repository
- Open the CodeCommit console.
- You should select the desired AWS Region In the region selector.
- Select Create repository on the Repositories page.
- Then, enter a name for the repository in the Repository name.
- Although, this step is optional. But, this will help you and other users to identify the purpose of the repository. There, you have to enter a description for the repository.
- You can skip this step as well. This step helps you to organize and manage your AWS resources. There, you need to select Add tag to add one or more to your repository.
- At last choose Create.
Well done! you are done! Now, the repository will appear in the Repositories list.
Step 2: Clone the CodeCommit Repository
In this step, you need to create a local repo to clone a Git repository on your local computer. Then, you should push the contents of the local repo to the CodeCommit repository you created earlier.
- From the terminal or prompt on your native pc, run the git clone command with the –mirror option to clone a bare copy of the remote repository into a new folder. This is merely for migration, not for interacting with the migrated repository in CodeCommit.
- You should change directories to the directory where you made the clone.
- You should specify the URL and name of the destination CodeCommit repository to run the git push command.
Congratulations! You are doing well!
Step 3: View Files in CodeCommit
After you are done with step 2, you can view all the files in that repository by using the CodeCommit console.
- You should open the CodeCommit console.
- In Repositories, you should choose the name of the repository.
- View the files in the repository for the branches, the clone URLs, the settings, and more.
Step 4: Share the CodeCommit Repository
When you create a repository in CodeCommit, two endpoints are generated: one for HTTPS connections and one for SSH connections. Both endpoints stay active whichever protocol you recommend to your users. Before sharing your repository with others, you must create IAM policies that allow other users to access your repository.
Create a customer-managed policy for your repository
- Firstly, you should sign in to the AWS Management Console and then, should open the IAM console.
- In the Dashboard navigation area, you should select Policies, and then, choose Create Policy.
- On the Create Policy page, next to Copy an AWS Managed Policy, you should choose Select.
- On the Copy, an AWS Managed Policy page, in Search Policies, you must enter AWSCodeCommitPowerUser. You should choose Select next to the policy name.
- On the Review Policy page, in Policy Name, you must enter a new name for the policy.
- You should choose the Validate Policy. After the policy is validated, you must choose Create Policy.
To manage access to your repository, create an IAM group and add IAM users in that group, and then, attach the customer managed policy you created in the previous step or any other policies required for access.
- Firstly, sign in to the AWS management console and open the IAM console.
- In the Dashboard navigation area, you must choose Groups, and then, choose Create New Group.
- On the Set Group Name page, in Group Name, enter a name for the group, and then, choose Next Step. You should include the repository name as part of the group name.
- Now, you should select the box next to the customer-managed policy you created in the previous section.
- On the Review page, you should select Create Group. IAM creates this group with the specified policies already attached. The group will appear in the list of groups linked with your AWS account.
- You must choose your group from the list.
- On the group summary page, you should choose the Users tab, and then, should choose Add Users to Group. On the list that shows all users associated with your AWS account, you must select the boxes next to the users to whom you are willing to allow access of the CodeCommit repository, and then, should choose Add Users.
- After adding your users, close the IAM console.
After you have created an IAM user to access CodeCommit using the policy group and policies you configured, send users the information required to connect to the repository.
- Open the CodeCommit console.
- In the region selector, you must choose the AWS Region where the repository is created.
- On the Repositories page, you need to find the name of the desired repository to share.
- In Clone URL, you should choose the desired protocol for your users’ use.
- You should send your users the clone URL along with any other instructions. And ensure to include the configuration information for the connection protocol.