/setup-aws-code-commit

How to setup AWS Code Commit using SSH and IAM roles. 🎓 Setup SSH key to enable IAM users to connect to Code Commit!

Welcome to AWS Code Commit

You can use the AWS Management Console and upload, add, or edit a file to a repository directly from the AWS CodeCommit console. This is a quick way to make a change. However, if you want to work with multiple files, files across branches, and so on, consider setting up your local computer to work with repositories. In this demo, we will learn how to setup AWS Code Commit using SSH and IAM roles.

Set Up SSH Connections to AWS CodeCommit Repositories

Follow this article in Youtube

Set Up SSH Connections to AWS CodeCommit Repositories

Note: This is for Linux/Mac users.

  1. Create IAM Users/Groups

    It is better to have a seperate groups(say Devs) and add your users to that group.

    Add Group Permission - Managed Policy - AWSCodeCommitFullAccess

  2. Create SSH Keys

    # Create the `.ssh` directory if it isn't there already
    # mkdir -p $HOME/.ssh
    cd $HOME/.ssh
    ssh-keygen
    # [here just create the name codecommit_rsa and leave all fields blank *just click enter*]
    cat codecommit_rsa.pub  
  3. Associate Your Public Key with Your IAM User

    • Now we need to enter our codecommit_rsa.pub into AWS IAM.
    • Copy the SSH key ID (for example, APKAEIBAERJR2EXAMPLE)
  4. Add AWS CodeCommit to Your SSH Configuration

    cd $HOME/.ssh
    touch config
    chmod 600 config
    cat > $HOME/.ssh/config << "EOF"
    Host git-codecommit.*.amazonaws.com
      User YOUR_SSH_KEY_ID_FROM_IAM
      IdentityFile ~/.ssh/codecommit_rsa
    EOF
  5. Test your SSH configuration:

    ssh git-codecommit.us-east-1.amazonaws.com

You should see something like this,

You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit. Interactive shells are not supported.Connection to git-codecommit.us-east-1.amazonaws.com closed by remote host.