Skip to content

Instantly share code, notes, and snippets.

@WillSams
Last active June 29, 2021 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WillSams/89ee0dd648548c03dc592ed860137e54 to your computer and use it in GitHub Desktop.
Save WillSams/89ee0dd648548c03dc592ed860137e54 to your computer and use it in GitHub Desktop.
Setting Up IAM User for AWS CodeCommit

Setting up for AWS CodeCommit

Create a new IAM User for Developer to Use Striclty For Development

  1. Navigate to IAM within the AWS Console.
  2. Create a new user. For this example instructions, we'll set the username to be test-user-dev. For AWS access type, just check the Programmatic access checkbox.
  3. Create a new group to use for developers to have access to one or more repositories. For this example, we'll create a new group called dev-team. Attach the AWSCodeCommitPowerUser policy to this new group.
  4. Click through the other defaults to create the new user.

Generate a new key

  1. Just selecting defaults is fine, but for this example we'll name the key id_codecommit_rsa.

    cd ~/.ssh
    ssh-keygen 

Update the IAM User with Public SSH Key

  1. Copy the SSH public key to your clipboard using xclip.

    sudo apt update && sudo apt upgrade -y
    sudo apt install xclip
    
    xclip -selection clipboard < ~/.ssh/id_codecommit_rsa.pub
  2. Back in IAM, look up test-user-dev. On the Security Credentials tab, click Upload SSH public key. Paste in the details from you clipboard in and save the details.

  3. Copy the SSH key ID generated for you to be used in the final step.

Add public key to the CodeCommit user created

  1. Add the host to you SSH configuration.

    echo '
    Host git-codecommit.*.amazonaws.com
    User <<The SSH key ID you received once you copied your public key into AWS>>
    IdentityFile ~/.ssh/id_codecommit_rsa' >> ~/.ssh/config
  2. Do a sanity check by running ssh git-codecommit.us-east-1.amazonaws.com to ensure your account works.

  3. Now you should be able to clone your Code Commit Git repositories. As an example:

    # This is only an example:
    git clone ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/my-test-repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment