HTTPS
In order to be able to work with the Git repository in CodeCommit using the AIM role, AWS Cli must be installed on the instance. You will also need "credential-helper", for this we create a configuration file for Git:
~/.gitconfig
And copy the following into it:
[credential] helper = !aws codecommit credential-helper $@ UseHttpPath = true
Now you can work with CodeCommit over HTTPS without specifying a username/password.
SSH
To use the SSH protocol, you need an IAM user with rights to CodeCommit. You also need to add the SSH Public Key, for this, in the IAM settings of the user, go to the "Security Credentials" tab and go down to the "SSH keys for AWS CodeCommit" block
And upload the public key. After which you will see the "SSH Key ID" of your key, it is needed to work with CodeCommit:
git clone ssh://{YOUR_ID_FOR_SSH_KEY}@git-codecommit.us-east-1.amazonaws.com/v1/repos/artem-test
But in order not to constantly indicate it, you can specify it in the SSH configuration:
vim ~/.ssh/config
Copy the following contents:
Host git-codecommit.*.amazonaws.com User {YOUR_ID_FOR_SSH_KEY} IdentityFile ~/.ssh/id_rsa # path to your private ssh key
And provide the necessary permission to it:
chmod 600 ~/.ssh/config
Now you can work with CodeCommit without specifying "SSH Key ID"