- The HTTPS URL: you are using either Git credentials with your IAM user or the credential helper included with the AWS CLI.
git clone https://git-codecommit.cn-northwest-1.amazonaws.com.cn/v1/repos/MyDemoRepo
- The HTTPS (GRC) URL: you are using the git-remote-codecommit command on your local computer.
git clone codecommit::cn-northwest-1://MyDemoRepo
- The SSH URL: you are using an SSH public/private key pair with your IAM user.
git clone ssh://git-codecommit.cn-northwest-1.amazonaws.com.cn/v1/repos/MyDemoRepo
-
create the new IAM user with AWSCodeCommitPowerUser permission or you can use the existed user by check/add AWSCodeCommitPowerUser permission
-
Working on CodeCommit Reposiotry Get Start Codecommit
-
create the new IAM user with AWSCodeCommitPowerUser permission or you can use the existed user by check/add AWSCodeCommitPowerUser permission
-
To install and configure the AWS CLI
aws codecommit help
# Configure the AWS CLI with a profile
aws configure
- Install git-remote-codecommit
pip install git-remote-codecommit
.....
Successfully built git-remote-codecommit
Installing collected packages: git-remote-codecommit
Successfully installed git-remote-codecommit-1.13
- Connect to the CodeCommit Console and Clone the Repository Note: git_remote_codecommit now has issue to support China region aws/git-remote-codecommit#10
You may encounter below error when run git clone codecommit://MyDemoRepo
The following AWS Region is not available for use with AWS CodeCommit: cn-northwest-1. For more information about CodeCommit's availability in AWS Regions, see the AWS CodeCommit User Guide. If an AWS Region is listed as supported but you receive this error, try updating your version of the AWS CLI or the AWS SDKs.
Workaround:
edit the file
<YOUR_CURRENT_PYTHON_DIR>/site-packages/git_remote_codecommit/__init__.py
locate the line:
available_regions = [region for partition in session.get_available_partitions() for region in session.get_available_regions('codecommit', partition)]
(Added in >>>) available_regions.append("cn-north-1")
(Added in >>>) available_regions.append("cn-northwest-1")
Clone your repository
# with default aws configure profile
git clone codecommit://MyDemoRepo
Cloning into 'MyDemoRepo'...
remote: Counting objects: 20, done.
Unpacking objects: 100% (20/20), done.
# with a specific aws configure profile
git clone codecommit://cn-north-1@MyDemoRepo
Cloning into 'MyDemoRepo'...
remote: Counting objects: 20, done.
Unpacking objects: 100% (20/20), done.
# with profile and region
git clone codecommit::cn-northwest-1://cn-north-1@MyDemoRepo
Cloning into 'MyDemoRepo'...
remote: Counting objects: 20, done.
Unpacking objects: 100% (20/20), done.
- Set Up the Public and Private Keys for Git and CodeCommit
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa): codecommit_rsa
cat ~/.ssh/codecommit_rsa.pub
# Copy the output
- In the IAM console, choose your
IAM user
.
- Choose the
Security Credentials
tab, and then chooseUpload SSH public key
. - Paste the
contents of your SSH public key
into the field, and then chooseUpload SSH public key
. - Copy or save the information in
SSH Key ID
.
- Edit ~/.ssh/config by add below line
Host git-codecommit.*.amazonaws.com.cn
User {SSH Key ID}
IdentityFile ~/.ssh/codecommit_rsa
- Testing
ssh git-codecommit.cn-northwest-1.amazonaws.com.cn
You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit. Interactive shells are not supported.Connection to git-codecommit.cn-northwest-1.amazonaws.com.cn closed by remote host.
Connection to git-codecommit.cn-northwest-1.amazonaws.com.cn closed.
# OR
ssh -v git-codecommit.cn-northwest-1.amazonaws.com.cn
# git clone
git clone ssh://git-codecommit.cn-northwest-1.amazonaws.com.cn/v1/repos/MyDemoRepo