CodeCommit Setup Step1 PDF
CodeCommit Setup Step1 PDF
CodeCommit Setup Step1 PDF
User Guide
API Version 2015-04-13
AWS CodeCommit User Guide
Table of Contents
....................................................................................................................................................... ix
What Is AWS CodeCommit? ................................................................................................................. 1
Introducing AWS CodeCommit ..................................................................................................... 1
How Does AWS CodeCommit Work? ............................................................................................. 2
How Is AWS CodeCommit Different from File Versioning in Amazon S3? ............................................ 3
How Do I Get Started with AWS CodeCommit? .............................................................................. 3
Where Can I Learn More About Git? ............................................................................................. 3
Setting Up ........................................................................................................................................ 4
Setting Up Using Git Credentials .................................................................................................. 4
Setting Up Using Other Methods ................................................................................................. 4
Compatibility for AWS CodeCommit, Git, and Other Components ..................................................... 5
For HTTPS Users Using Git Credentials ......................................................................................... 5
Step 1: Initial Configuration for AWS CodeCommit ................................................................. 6
Step 2: Install Git ............................................................................................................... 6
Step 3: Create Git Credentials for HTTPS Connections to AWS CodeCommit ............................... 7
Step 4: Connect to the AWS CodeCommit Console and Clone the Repository .............................. 8
Next Steps ........................................................................................................................ 9
For Connections from Development Tools ..................................................................................... 9
Integrate AWS Cloud9 with AWS CodeCommit ..................................................................... 12
Integrate Visual Studio with AWS CodeCommit .................................................................... 15
Integrate Eclipse with AWS CodeCommit ............................................................................. 19
For SSH Users Not Using the AWS CLI ........................................................................................ 23
Step 1: Associate Your Public Key with Your IAM User ........................................................... 24
Step 2: Add AWS CodeCommit to Your SSH Configuration ..................................................... 24
Next Steps ....................................................................................................................... 25
For SSH Connections on Linux, macOS, or Unix ............................................................................ 25
Step 1: Initial Configuration for AWS CodeCommit ............................................................... 25
Step 2: Install Git ............................................................................................................. 26
Step 3: Configure Credentials on Linux, macOS, or Unix ........................................................ 26
Step 4: Connect to the AWS CodeCommit Console and Clone the Repository ............................ 28
Next Steps ....................................................................................................................... 29
For SSH Connections on Windows .............................................................................................. 29
Step 1: Initial Configuration for AWS CodeCommit ............................................................... 30
Step 2: Install Git ............................................................................................................. 30
SSH and Windows: Set Up the Public and Private Keys for Git and AWS CodeCommit ................. 31
Step 4: Connect to the AWS CodeCommit Console and Clone the Repository ............................ 33
Next Steps ....................................................................................................................... 33
For HTTPS Connections on Linux, macOS, or Unix with the AWS CLI Credential Helper ....................... 34
Step 1: Initial Configuration for AWS CodeCommit ............................................................... 34
Step 2: Install Git ............................................................................................................. 36
Step 3: Set Up the Credential Helper .................................................................................. 36
Step 4: Connect to the AWS CodeCommit Console and Clone the Repository ............................ 37
Next Steps ....................................................................................................................... 38
For HTTPS Connections on Windows with the AWS CLI Credential Helper ........................................ 38
Step 1: Initial Configuration for AWS CodeCommit ............................................................... 38
Step 2: Install Git ............................................................................................................. 40
Step 3: Set Up the Credential Helper .................................................................................. 40
Step 4: Connect to the AWS CodeCommit Console and Clone the Repository ............................ 42
Next Steps ....................................................................................................................... 42
Getting Started ................................................................................................................................ 43
AWS CodeCommit Tutorial ........................................................................................................ 43
Step 1: Create an AWS CodeCommit Repository ................................................................... 45
Step 2: Add Files to Your Repository ................................................................................... 46
Step 3: Browse the Contents of Your Repository ................................................................... 48
Git for Windows: I Installed Git for Windows, but I Am Denied Access to My Repository (403) ..... 235
Troubleshooting Git Clients ...................................................................................................... 237
Git Error: error: RPC failed; result=56, HTTP code = 200 fatal: The remote end hung up
unexpectedly .................................................................................................................. 237
Git Error: Too many reference update commands ............................................................... 237
Git Error: push via HTTPS is broken in some versions of Git .................................................. 237
Git Error: 'gnutls_handshake() failed' ................................................................................. 237
Git Error: Git cannot find the AWS CodeCommit repository or does not have permission to
access the repository ...................................................................................................... 238
Git on Windows: No Supported Authentication Methods Available (publickey) ......................... 238
Troubleshooting Access Errors .................................................................................................. 238
Access Error: Prompted for AWS User Name When Connecting to an AWS CodeCommit
Repository ..................................................................................................................... 239
Access Error: Prompted for User Name and Password When Connecting to an AWS
CodeCommit Repository from Windows ............................................................................ 239
Access Error: Public Key Denied When Connecting to an AWS CodeCommit Repository ............. 239
Troubleshooting Configuration Errors ........................................................................................ 240
Configuration Error: Cannot Configure AWS CLI Credentials on macOS .................................. 240
Troubleshooting Console Errors ................................................................................................ 240
Access Error: Encryption Key Access Denied for an AWS CodeCommit Repository from the
Console or the AWS CLI .................................................................................................. 240
Console Error: Cannot Browse the Code in an AWS CodeCommit Repository from the Console ... 241
Troubleshooting Triggers ......................................................................................................... 241
Trigger Error: A Repository Trigger Does Not Run When Expected ......................................... 241
Turn on Debugging ................................................................................................................. 241
Authentication and Access Control .................................................................................................... 243
Authentication ....................................................................................................................... 243
Access Control ........................................................................................................................ 244
Overview of Managing Access .................................................................................................. 244
Resources and Operations ............................................................................................... 245
Understanding Resource Ownership .................................................................................. 246
Managing Access to Resources ......................................................................................... 246
Resource Scoping in AWS CodeCommit ............................................................................. 247
Specifying Policy Elements: Resources, Actions, Effects, and Principals ................................... 248
Specifying Conditions in a Policy ...................................................................................... 248
Using Identity-Based Policies (IAM Policies) ................................................................................ 249
Permissions Required to Use the AWS CodeCommit Console ................................................ 249
AWS Managed (Predefined) Policies for AWS CodeCommit ................................................... 251
Customer Managed Policy Examples ................................................................................. 256
AWS CodeCommit Permissions Reference .................................................................................. 262
Required Permissions for Git Client Commands .................................................................. 262
Permissions for Actions on Branches ................................................................................. 263
Permissions for Actions on Pull Requests ........................................................................... 264
Permissions for Actions on Individual Files ......................................................................... 266
Permissions for Actions on Comments ............................................................................... 266
Permissions for Actions on Committed Code ...................................................................... 267
Permissions for Actions on Repositories ............................................................................. 269
Permissions for Actions on Triggers .................................................................................. 270
Permissions for Actions on AWS CodePipeline Integration .................................................... 270
AWS CodeCommit Reference ............................................................................................................ 272
Regions and Git Connection Endpoints ...................................................................................... 272
Supported Regions for AWS CodeCommit .......................................................................... 272
Git Connection Endpoints ................................................................................................ 273
Server Fingerprints for AWS CodeCommit .......................................................................... 275
Limits .................................................................................................................................... 277
Temporary Access ................................................................................................................... 279
Step 1: Complete the Prerequisites ................................................................................... 280
The procedures in this guide support the new console design. If you choose to use the older version of
the console, you will find many of the concepts and basic procedures in this guide still apply. To access
help in the new console, choose the information icon.
Topics
• Introducing AWS CodeCommit (p. 1)
• How Does AWS CodeCommit Work? (p. 2)
• How Is AWS CodeCommit Different from File Versioning in Amazon S3? (p. 3)
• How Do I Get Started with AWS CodeCommit? (p. 3)
• Where Can I Learn More About Git? (p. 3)
• Benefit from a fully managed service hosted by AWS. AWS CodeCommit provides high service
availability and durability and eliminates the administrative overhead of managing your own hardware
and software. There is no hardware to provision and scale and no server software to install, configure,
and update.
• Store your code securely. AWS CodeCommit repositories are encrypted at rest as well as in transit.
• Work collaboratively on code. AWS CodeCommit repositories support pull requests, where users can
review and comment on each other's code changes before merging them to branches; notifications
that automatically send emails to users about pull requests and comments; and more.
• Easily scale your version control projects. AWS CodeCommit repositories can scale up to meet your
development needs. The service can handle repositories with large numbers of files or branches, large
file sizes, and lengthy revision histories.
• Store anything, anytime. AWS CodeCommit has no limit on the size of your repositories or on the file
types you can store.
• Integrate with other AWS and third-party services. AWS CodeCommit keeps your repositories close
to your other production resources in the AWS Cloud, which helps increase the speed and frequency of
your development lifecycle. It is integrated with IAM and can be used with other AWS services and in
parallel with other repositories. For more information, see Product and Service Integrations with AWS
CodeCommit (p. 68).
• Easily migrate files from other remote repositories. You can migrate to AWS CodeCommit from any
Git-based repository.
• Use the Git tools you already know. AWS CodeCommit supports Git commands as well as its own
AWS CLI commands and APIs.
The following figure shows how you use your development machine, the AWS CLI or AWS CodeCommit
console, and the AWS CodeCommit service to create and manage repositories:
1. Use the AWS CLI or the AWS CodeCommit console to create an AWS CodeCommit repository.
2. From your development machine, use Git to run git clone, specifying the name of the AWS
CodeCommit repository. This creates a local repo that connects to the AWS CodeCommit repository.
3. Use the local repo on your development machine to modify (add, edit, and delete) files, and then
run git add to stage the modified files locally. Run git commit to commit the files locally, and then
run git push to send the files to the AWS CodeCommit repository.
4. Download changes from other users. Run git pull to synchronize the files in the AWS CodeCommit
repository with your local repo. This ensures you're working with the latest version of the files.
You can use the AWS CLI or the AWS CodeCommit console to track and manage your repositories.
• Pro Git, an online version of the Pro Git book. Written by Scott Chacon. Published by Apress.
• Git Immersion, a try-it-yourself guided tour that walks you through the fundamentals of using Git.
Published by Neo Innovation, Inc.
• Git Reference, an online quick reference that can also be used as a more in-depth Git tutorial.
Published by the GitHub team.
• Git Cheat Sheet with basic Git command syntax. Published by the GitHub team.
• Git Pocket Guide. Written by Richard E. Silverman. Published by O'Reilly Media, Inc.
You can use other methods if you do not want to or cannot use Git credentials for operational reasons.
Read through these other options carefully, to decide which alternate method will work best for you.
• For HTTPS Users Using Git Credentials (p. 5): Follow these instructions to set up connections
between your local computer and AWS CodeCommit repositories using Git credentials.
• For Connections from Development Tools (p. 9): Follow these guidelines to set up connections
between your IDE or other development tools and AWS CodeCommit repositories using Git credentials.
IDEs that support Git credentials include (but are not limited to) Visual Studio, Eclipse, Xcode, and
IntelliJ.
Unlike Git credentials, SSH connection setup will vary, depending on the operating system on your local
computer.
• For SSH Users Not Using the AWS CLI (p. 23): Follow these abbreviated instructions if you already
have a public-private key pair and are familiar with SSH connections on your local computer.
• For SSH Connections on Linux, macOS, or Unix (p. 25): Follow these instructions for a step-by-step
walkthrough of creating a public-private key pair and setting up connections on Linux, macOS, or Unix
operating systems.
• For SSH Connections on Windows (p. 29): Follow these instructions for a step-by-step walkthrough
of creating public-private key pair and setting up connections on Windows operating systems.
If you are connecting to AWS CodeCommit and AWS using federated access or temporary credentials, or
if you do not want to configure IAM users, you can set up connections to AWS CodeCommit repositories
using the credential helper included in the AWS CLI. The credential helper allows Git to use HTTPS and
a cryptographically signed version of your IAM user credentials or Amazon EC2 instance role whenever
Git needs to authenticate with AWS to interact with AWS CodeCommit repositories. This is the only
connection method for AWS CodeCommit repositories that does not require an IAM user, so it is the
only method that supports federated access and temporary credentials. Some operating systems and
Git versions have their own credential helpers, which conflict with the credential helper included in the
AWS CLI. They can cause connectivity issues for AWS CodeCommit. For ease of use, consider creating IAM
users and configuring Git credentials with HTTPS connections instead of using the credential helper.
• For HTTPS Connections on Linux, macOS, or Unix with the AWS CLI Credential Helper (p. 34): Follow
these instructions for a step-by-step walkthrough of installing and setting up the credential helper on
Linux, macOS, or Unix systems.
• For HTTPS Connections on Windows with the AWS CLI Credential Helper (p. 38): Follow these
instructions for a step-by-step walkthrough of installing and setting up the credential helper on
Windows systems.
If you are connecting to an AWS CodeCommit repository that is hosted in another AWS account, you can
configure access and set up connections using roles, policies, and the credential helper included in the
AWS CLI.
• Configure Cross-Account Access to an AWS CodeCommit Repository (p. 118): Follow these
instructions for a step-by-step walkthrough of configuring cross-account access in one AWS account to
users in an IAM group in another AWS account.
Component Version
(IDE) that supports HTTPS authentication using a static user name and password. For examples, see For
Connections from Development Tools (p. 9).
Note
If you have previously configured your local computer to use the credential helper for AWS
CodeCommit, you must edit your .gitconfig file to remove the credential helper information
from the file before you can use Git credentials. If your local computer is running macOS, you
might need to clear cached credentials from Keychain Access.
After you have selected the policy you want to attach, choose Next: Review to review the list of
policies that will be attached to the IAM user. If the list is correct, choose Add permissions.
For more information about AWS CodeCommit managed policies and sharing access to repositories
with other groups and users, see Share a Repository (p. 81) and Authentication and Access
Control for AWS CodeCommit (p. 243).
If you want to use AWS CLI commands with AWS CodeCommit, install the AWS CLI. For more
information, see Command Line Reference (p. 289).
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
Make sure to sign in as the IAM user who will create and use the Git credentials for connections to
AWS CodeCommit.
2. In the IAM console, in the navigation pane, choose Users, and from the list of users, choose your IAM
user.
3. On the user details page, choose the Security Credentials tab, and in HTTPS Git credentials for
AWS CodeCommit, choose Generate.
Note
You cannot choose your own user name or password for Git credentials. For more
information, see Use Git Credentials and HTTPS with AWS CodeCommit.
4. Copy the user name and password that IAM generated for you, either by showing, copying, and
pasting this information into a secure file on your local computer, or by choosing Download
credentials to download this information as a .CSV file. You will need this information to connect to
AWS CodeCommit.
If you see a Welcome page instead of a list of repositories, there are no repositories associated with
your AWS account. To create a repository, see the section called “Create a Repository” (p. 76) or
follow the steps in the Git with AWS CodeCommit Tutorial (p. 58) tutorial.
4. Choose Connect. Review the instructions and copy the URL to use when connecting to the
repository.
5. Open a terminal, command line, or Git shell. Using the HTTPS URL you copied, run the git clone
command to clone the repository. For example, to clone a repository named MyDemoRepo to a local
repo named my-demo-repo in the US East (Ohio) region:
The first time you connect, you will be prompted to provide the user name and password for the
repository. Depending on the configuration of your local computer, this prompt will either originate
from a credential management system for the operating system (for example, Keychain Access
for macOS), a credential manager utility for your version of Git (for example, the Git Credential
Manager included in Git for Windows), your IDE, or Git itself. Provide the user name and password
generated for Git credentials in IAM (the ones you created in Step 3: Create Git Credentials for
HTTPS Connections to AWS CodeCommit (p. 7)). Depending on your operating system and other
software, this information might be saved for you in a credential store or credential management
utility. If so, you should not be prompted again unless you change the password, inactivate the Git
credentials, or delete the Git credentials in IAM.
If you do not have a credential store or credential management utility configured on your local
computer, you can install one. For more information about Git and how it manages credentials, see
Credential Storage in the Git documentation.
For more information, see Connect to the AWS CodeCommit Repository by Cloning the
Repository (p. 79) and Create a Commit (p. 161).
Next Steps
You have completed the prerequisites. Follow the steps in AWS CodeCommit Tutorial (p. 43) to start
using AWS CodeCommit.
Topics
• Integrate AWS Cloud9 with AWS CodeCommit (p. 12)
• Integrate Visual Studio with AWS CodeCommit (p. 15)
• Integrate Eclipse with AWS CodeCommit (p. 19)
When prompted by your IDE or development tool for the user name and password used to connect to
the AWS CodeCommit repository, provide the Git credentials for User name and Password you created in
IAM. For example, if you are prompted for a user name and password in Eclipse, you would provide your
Git credentials as follows:
For more information about regions and endpoints for AWS CodeCommit, see Regions and Git
Connection Endpoints (p. 272).
You might also see a prompt from your operating system to store your user name and password. For
example, in Windows, you would provide your Git credentials as follows:
For more information about configuring Git credentials for a particular software program or
development tool, consult the product documentation.
The following is not a comprehensive list of IDEs. AWS is not responsible for the content of any of these
topics. The links are provided solely to help you learn more about these tools.
• Visual Studio
Alternatively, install the AWS Toolkit for Visual Studio. For more information, see Integrate Visual
Studio with AWS CodeCommit (p. 15).
Alternatively, install the AWS Toolkit for Eclipse. For more information, see Integrate Eclipse with AWS
CodeCommit (p. 19).
• IntelliJ
• XCode
To use AWS Cloud9 with AWS CodeCommit, you need the following:
For more information, see AWS Managed (Predefined) Policies for AWS CodeCommit (p. 251) and
Understanding and Getting Your Security Credentials.
Topics
• Step 1: Create an AWS Cloud9 Development Environment (p. 13)
• Step 2: Configure the AWS CLI Credential Helper On Your AWS Cloud9 EC2 Development
Environment (p. 14)
• Step 3: Clone an AWS CodeCommit Repository Into Your AWS Cloud9 EC2 Development
Environment (p. 15)
• Next Steps (p. 15)
1. Sign in to AWS as the IAM user you've configured and open the AWS Cloud9 console.
2. In the AWS Cloud9 console, choose Create environment.
3. In Step 1: Name environment, type a name for your development environment in Name. Optionally
add a description for the environment, and then choose Next step.
4. In Step 2: Configure Settings, configure your environment as follows:
Creating an environment and connecting to it for the first time takes several minutes. If it seems to
take an unusally long time, see Troubleshooting in the AWS Cloud9 User Guide.
6. Once you are connected to your environment, check to see if Git is already installed and is a
supported version by running the git --version command in the terminal window.
If Git is not installed, or if it is not a supported version, install a supported version. AWS
CodeCommit supports Git versions 1.7.9 and later. To install Git, we recommend websites such as Git
Downloads.
Tip
Depending on the operating system of your environment, you might be able to use the
yum command with the sudo option to install updates, including Git. For example, an
administrative command sequence might resemble the following three commands:
7. Configure a user name and email to be associated with your Git commits by running the git config
command. For example:
1. Open the terminal window and type the following command to verify that the AWS CLI is installed:
aws --version
If successful, this command returns the currently-installed version of the AWS CLI. To upgrade an
older version of the AWS CLI to the latest version, see Installing the AWS Command Line Interface.
2. At the terminal, type the following commands to configure the AWS CLI Credential Helper for
HTTPS connections:
Tip
The credential helper will use the default Amazon EC2 instance role for your development
environment. If you intend to use the development environment to connect to repositories
that are not hosted in AWS CodeCommit, either configure SSH connections to those
repositories, or configure a local .gitconfig file to use an alternative credential
management system when connecting to those other repositories. For more information,
see Git Tools - Credential Storage on the Git website.
1. In the terminal, run the git clone command, specifying the HTTPS clone URL of the repository you
want to clone. For example, if you want to clone a repository named MyDemoRepo in the US East
(Ohio) region, you would type:
Tip
You can find the Clone URL for your repository in the AWS CodeCommit console, both in
Repositories, and in the Clone URL information on the Code page of the repository itself.
2. When the cloning is complete, expand the folder for your repository in the side navigation, and
choose the file you want to open for editing. Alternatively, choose File and then choose New File to
create a new file.
3. When you have finished editing or creating files, in the terminal window, change directories to your
cloned repository and then commit and push your changes. For example, if you added a new file
named MyFile.py:
cd MyDemoRepo
git commit -a MyFile.py
git commit -m "Added a new file with some code improvements"
git push
Next Steps
To learn more about using AWS Cloud9, see the AWS Cloud9 User Guide. To learn more about using Git
with AWS CodeCommit, see Git with AWS CodeCommit Tutorial (p. 58).
Important
The Toolkit for Visual Studio is available for installation on Windows operating systems only.
If you've used the Toolkit for Visual Studio before, you're probably already familiar with setting up AWS
credential profiles that contain an access key and secret key. Credential profiles are used in the Toolkit
for Visual Studio to enable calls to AWS service APIs (for example, to Amazon S3 to list buckets or to
AWS CodeCommit to list repositories). To pull and push code to an AWS CodeCommit repository, you
also need Git credentials. If you don't have Git credentials, the Toolkit for Visual Studio can generate and
apply those credentials for you. This can save you a great deal of time.
To use Visual Studio with AWS CodeCommit, you need the following:
• An IAM user with a valid set of credentials (an access key and secret key) configured for it. This IAM
user should also have:
OR
If the IAM user already has Git credentials configured, one of the AWS CodeCommit managed policies
or equivalent permissions.
For more information, see AWS Managed (Predefined) Policies for AWS CodeCommit (p. 251) and
Understanding and Getting Your Security Credentials.
• The AWS Toolkit for Visual Studio installed on the computer where you've installed Visual Studio. For
more information, see Setting Up the AWS Toolkit for Visual Studio.
Topics
• Step 1: Get an Access Key and Secret Key for Your IAM User (p. 16)
• Step 2: Install AWS Toolkit for Visual Studio and Connect to AWS CodeCommit (p. 17)
• Clone an AWS CodeCommit Repository from Visual Studio (p. 18)
• Create an AWS CodeCommit Repository from Visual Studio (p. 18)
• Working with AWS CodeCommit Repositories (p. 19)
Step 1: Get an Access Key and Secret Key for Your IAM User
If you do not already have a credential profile set up on the computer where Visual Studio is installed,
you can configure one with the AWS CLI and the aws configure command. Alternatively, you can follow
this procedure to create and download your credentials. Provide them to the Toolkit for Visual Studio
when prompted.
To get the access key ID and secret access key for an IAM user
Access keys consist of an access key ID and secret access key, which are used to sign programmatic
requests that you make to AWS. If you don't have access keys, you can create them from the AWS
Management Console. We recommend that you use IAM access keys instead of AWS account root user
access keys. IAM lets you securely control access to AWS services and resources in your AWS account.
The only time that you can view or download the secret access keys is when you create the keys. You
cannot recover them later. However, you can create new access keys at any time. You must also have
permissions to perform the required IAM actions. For more information, see Permissions Required to
Access IAM Resources in the IAM User Guide.
Keep the keys confidential in order to protect your AWS account, and never email them. Do not
share them outside your organization, even if an inquiry appears to come from AWS or Amazon.com.
No one who legitimately represents Amazon will ever ask you for your secret key.
Related topics
To install the Toolkit for Visual Studio with the AWS CodeCommit module and configure
access to your project repository
1. Install Visual Studio on your local computer if you don't have a supported version already installed.
2. Download and install the Toolkit for Visual Studio and save the file to a local folder or directory.
Launch the installation wizard by opening the file. When prompted on the Getting Started with
the AWS Toolkit for Visual Studio page, type or import your AWS credentials (your access key and
secret key), and then choose Save and Close.
3. In Visual Studio, open Team Explorer. In Hosted Service Providers, find AWS CodeCommit, and
choose Connect.
• If you have a single credential profile already configured on your computer, the Toolkit for Visual
Studio will apply it automatically. No action is required. The AWS CodeCommit connection panel
appears in Team Explorer.
• If you have more than one credential profile configured on your computer, you are prompted to
choose the one you want to use. Choose the profile associated with the IAM user you'll use for
connecting to AWS CodeCommit repositories, and then choose OK.
• If you do not have a profile configured, a dialog box appears and asks for your AWS security
credentials (your access key and secret key). Type or import them, and then choose OK.
After you are signed in with a profile, the AWS CodeCommit connection panel appears in Team
Explorer with options to clone, create, or sign out. Choosing Clone clones an existing AWS CodeCommit
repository to your local computer, so you can start working on code. This is the most frequently used
option.
If you don't have repositories, or want to create a repository, choose Create. For more information, see
Create an AWS CodeCommit Repository from Visual Studio (p. 18).
1. In Manage Connections, choose Clone. In Region, choose the AWS region where the repository was
created in AWS CodeCommit. Choose your project's repository and the folder on your local computer
you want to clone the repository into, and then choose OK.
2. If you are prompted to create Git credentials, choose Yes. The toolkit attempts to create credentials
on your behalf. You must have the IAMSelfManageServiceSpecificCredentials applied to your IAM
user, or the equivalent permissions. When prompted, save the credentials file in a secure location.
This is the only opportunity you will have to save these Git credentials.
If the toolkit cannot create Git credentials on your behalf, or if you chose No, you must create
and provide your own Git credentials. For more information, see For HTTPS Users Using Git
Credentials (p. 5), or follow the online directions.
3. When you have finished cloning the project, you're ready to start editing your code in Visual Studio
and committing and pushing your changes to your project's repository in AWS CodeCommit.
If the toolkit cannot create Git credentials on your behalf, or if you chose No, you must create
and provide your own Git credentials. For more information, see For HTTPS Users Using Git
Credentials (p. 5), or follow the online directions.
Git operations in Visual Studio for AWS CodeCommit repositories work exactly as they do for any other
Git-based repository. You can make changes to code, add files, and create local commits. When you are
ready to share, you use the Sync option in Team Explorer to push your commits to the AWS CodeCommit
repository. Because your Git credentials for your IAM user are already stored locally and associated with
your connected AWS credential profile, you won’t be prompted to supply them again when you push to
AWS CodeCommit.
For more information about working with Toolkit for Visual Studio, see the AWS Toolkit for Visual Studio
User Guide.
To use Toolkit for Eclipse with AWS CodeCommit, you need the following:
OR
If the IAM user already has Git credentials configured, one of the AWS CodeCommit managed policies
or equivalent permissions .
For more information, see AWS Managed (Predefined) Policies for AWS CodeCommit (p. 251) and
Understanding and Getting Your Security Credentials.
• An active set of Git credentials configured for the user in IAM. For more information, see Step 3: Create
Git Credentials for HTTPS Connections to AWS CodeCommit (p. 7).
Topics
• Step 1: Get an Access Key and Secret Key for Your IAM User (p. 19)
• Step 2: Install AWS Toolkit for Eclipse and Connect to AWS CodeCommit (p. 20)
• Clone an AWS CodeCommit Repository from Eclipse (p. 21)
• Create an AWS CodeCommit Repository from Eclipse (p. 22)
• Working with AWS CodeCommit Repositories (p. 23)
Step 1: Get an Access Key and Secret Key for Your IAM User
If you do not already have a credential profile set up on the computer where Eclipse is installed, you
can configure one with the AWS CLI and the aws configure command. Alternatively, you can follow
this procedure to create and download your credentials. Provide them to the Toolkit for Eclipse when
prompted.
To get the access key ID and secret access key for an IAM user
Access keys consist of an access key ID and secret access key, which are used to sign programmatic
requests that you make to AWS. If you don't have access keys, you can create them from the AWS
Management Console. We recommend that you use IAM access keys instead of AWS account root user
access keys. IAM lets you securely control access to AWS services and resources in your AWS account.
The only time that you can view or download the secret access keys is when you create the keys. You
cannot recover them later. However, you can create new access keys at any time. You must also have
permissions to perform the required IAM actions. For more information, see Permissions Required to
Access IAM Resources in the IAM User Guide.
Keep the keys confidential in order to protect your AWS account, and never email them. Do not
share them outside your organization, even if an inquiry appears to come from AWS or Amazon.com.
No one who legitimately represents Amazon will ever ask you for your secret key.
Related topics
To install the Toolkit for Eclipse with the AWS CodeCommit module and configure access to
your project repository
1. Install Toolkit for Eclipse on your local computer if you don't have a supported version already
installed. If you need to update your version of Toolkit for Eclipse, follow the instructions in Set Up
the Toolkit.
2. In Eclipse, either follow the firstrun experience, or open Preferences from the Eclipse menu system
(the precise location will vary depending on your version and operating system) and choose AWS
Toolkit.
3. Do one of the following:
• If you are following the firstrun experience, provide your AWS security credentials when prompted
to set up your credential profile.
• If you are configuring in Preferences and have a credential profile already configured on your
computer, choose it from the list in Default Profile.
• If you are configuring in Preferences and you do not see the profile you want to use, or if the list
is empty, choose Add profile. In Profile Details, provide a name for the proifle and the credentials
for the IAM user (access key and secret key), or alternatively provide the location of the credentials
file.
• If you are configuring in Preferences and you do not have a profile configured, use the links for
signing up for a new account or managing your existing AWS security credentials.
4. In Eclipse, expand the AWS Toolkit menu and choose AWS CodeCommit. Choose your credential
profile, and then type the user name and password for your Git credentials or import them from
the .csv file. Choose Apply, and then choose OK.
After you are signed in with a profile, the AWS CodeCommit connection panel appears in Team
Explorer with options to clone, create, or sign out. Choosing Clone clones an existing AWS CodeCommit
repository to your local computer, so you can start working on code. This is the most frequently used
option.
If you don't have any repositories, or want to create a repository, choose Create.
1. In Eclipse, open AWS Explorer. For more information about where to find it, see How to Access AWS
Explorer. Expand AWS CodeCommit, and choose the AWS CodeCommit repository you want to
work in. You can view the commit history and other details of the repository, which can help you
determine if this is the repository and branch you want to clone.
Note
If you do not see your repository, choose the flag icon to open the AWS regions menu, and
choose the region where the repository was created.
2. Choose Check out, and follow the instructions to clone the repository to your local computer.
3. When you have finished cloning the project, you're ready to start editing your code in Eclipse and
staging, committing, and pushing your changes to your project's repository in AWS CodeCommit.
1. In AWS Explorer, right-click AWS CodeCommit, and then choose Create repository.
Note
Repositories are region-specific. Before you create the repository, make sure you have
selected the correct AWS region. You cannot choose the region after you have started the
repository creation process.
2. In Repository Name, type a name for this repository. Repository names must be unique within an
AWS account. There are character and length limits. For more information, see Limits (p. 277).
Optionally, in Repository Description, type a description for this repository. This helps others
understand what this repository is for, and helps distinguish it from other repositories in the region.
Choose OK.
3. In AWS Explorer, expand AWS CodeCommit, and then choose the AWS CodeCommit repository you
just created. You will see that this repository has no commit history. Choose Check out, and follow
the instructions to clone the repository to your local computer.
In Toolkit for Eclipse, you can browse the contents of these repositories from the Navigation and
Package Explorer views. To open a file, choose it from the list.
Git operations in Toolkit for Eclipse for AWS CodeCommit repositories work exactly as they do for any
other Git-based repository. You can make changes to code, add files, and create local commits. When
you are ready to share, you use the Git Staging option to push your commits to the AWS CodeCommit
repository. If you haven't configured your author and committer information in a Git profile, you can
do this before you commit and push. Because your Git credentials for your IAM user are already stored
locally and associated with your connected AWS credential profile, you won’t be prompted to supply
them again when you push to AWS CodeCommit.
For more information about working with Toolkit for Eclipse, see the AWS Toolkit for Eclipse Getting
Started Guide.
• You have set up an IAM user with the policies or permissions required for AWS CodeCommit as well as
the IAMUserSSHKeys managed policy or equivalent permissions required for uploading keys. For more
information, see Using Identity-Based Policies (IAM Policies) for AWS CodeCommit (p. 249).
• You already have, or know how to create, a public/private key pair. We strongly recommend you use a
secure passphrase for your SSH key.
• You are familiar with SSH, your Git client, and its configuration files.
• If you are using Windows, you have installed a command-line utility, such as Git Bash, that emulates
the bash shell.
If you need more guidance, follow the detailed instructions in For SSH Connections on Linux, macOS, or
Unix (p. 25) or For SSH Connections on Windows (p. 29).
Topics
• Step 1: Associate Your Public Key with Your IAM User (p. 24)
• Step 2: Add AWS CodeCommit to Your SSH Configuration (p. 24)
• Next Steps (p. 25)
ssh-rsa EXAMPLE-
AfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMCVVMxCzAJB
gNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb2
5zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhc
NMTEwNDI1MjA0NTIxWhcNMTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAw
DgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDAS=EXAMPLE user-
name@ip-192-0-2-137
IAM accepts public keys in the OpenSSH format only. If you provide your public key in
another format, you will see an error message stating the key format is not valid.
5. Copy the SSH key ID (for example, APKAEIBAERJR2EXAMPLE) and close the console.
Host git-codecommit.*.amazonaws.com
User Your-SSH-Key-ID, such as APKAEIBAERJR2EXAMPLE
IdentityFile Your-Private-Key-File, such as ~/.ssh/codecommit_rsa or ~/.ssh/id_rsa
Tip
If you have more than one SSH configuration, make sure you include the blank lines before
and after the content. Save the file by pressing the Ctrl and d keys simultaneously.
2. Run the following command to test your SSH configuration:
ssh git-codecommit.us-east-2.amazonaws.com
Type the passphrase for your SSH key file when prompted. If everything is configured correctly, you
should see the following success message:
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-2.amazonaws.com closed by remote host.
Next Steps
You have completed the prerequisites. Follow the steps in AWS CodeCommit Tutorial (p. 43) to start
using AWS CodeCommit.
To connect to an existing repository, follow the steps in Connect to a Repository (p. 78). To create a
repository, follow the steps in Create a Repository (p. 76).
Topics
• Step 1: Initial Configuration for AWS CodeCommit (p. 25)
• Step 2: Install Git (p. 26)
• Step 3: Configure Credentials on Linux, macOS, or Unix (p. 26)
• Step 4: Connect to the AWS CodeCommit Console and Clone the Repository (p. 28)
• Next Steps (p. 29)
Note
AWS CodeCommit requires AWS Key Management Service. If you are using an existing
IAM user, make sure there are no policies attached to the user that expressly deny the
AWS KMS actions required by AWS CodeCommit. For more information, see AWS KMS and
Encryption (p. 282).
3. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
4. In the IAM console, in the navigation pane, choose Users, and then choose the IAM user you want to
configure for AWS CodeCommit access.
5. On the Permissions tab, choose Add Permissions.
6. In Grant permissions, choose Attach existing policies directly.
7. Select AWSCodeCommitFullAccess from the list of policies, or another managed policy for AWS
CodeCommit access. For more information about managed policies for AWS CodeCommit, see AWS
Managed (Predefined) Policies for AWS CodeCommit (p. 251).
After you have selected the policy you want to attach, choose Next: Review to review the list of
policies that will be attached to the IAM user. If the list is correct, choose Add permissions.
For more information about AWS CodeCommit managed policies and sharing access to repositories
with other groups and users, see Share a Repository (p. 81) and Authentication and Access
Control for AWS CodeCommit (p. 243).
Note
If you want to use AWS CLI commands with AWS CodeCommit, install the AWS CLI. For more
information, see Command Line Reference (p. 289).
For example:
$ ssh-keygen
Enter passphrase (empty for no passphrase): <Type a passphrase, and then press Enter>
Enter same passphrase again: <Type the passphrase again, and then press Enter>
This generates:
cat ~/.ssh/codecommit_rsa.pub
ssh-rsa EXAMPLE-AfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMCVVMxCzAJB
gNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb2
5zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhc
NMTEwNDI1MjA0NTIxWhcNMTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAw
DgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDAS=EXAMPLE user-name@ip-192-0-2-137
3. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
4. In the IAM console, in the navigation pane, choose Users, and from the list of users, choose your IAM
user.
5. On the user details page, choose the Security Credentials tab, and then choose Upload SSH public
key.
6. Paste the contents of your SSH public key into the field, and then choose Upload SSH public key.
7. Copy or save the information in SSH Key ID (for example, APKAEIBAERJR2EXAMPLE).
8. On your local machine, use a text editor to create a config file in the ~/.ssh directory, and then add
the following lines to the file, where the value for User is the SSH key ID you copied earlier:
Host git-codecommit.*.amazonaws.com
User APKAEIBAERJR2EXAMPLE
IdentityFile ~/.ssh/codecommit_rsa
Note
If you gave your private key file a name other than codecommit_rsa, be sure to use it
here.
ssh git-codecommit.us-east-2.amazonaws.com
After you have confirmed the connection, you should see confirmation that you have added the
server to your known hosts file and a successful connection message. If you do not see a success
message, double-check that you saved the config file in the ~/.ssh directory of the IAM user you
configured for access to AWS CodeCommit, and that you specified the correct private key file.
For information to help you troubleshoot problems, run the ssh command with the -v parameter:
ssh -v git-codecommit.us-east-2.amazonaws.com
You can find more information to help you troubleshoot connection problems in
Troubleshooting (p. 228).
3. Choose the repository you want to connect to from the list. This opens the Code page for that
repository.
If you see a Welcome page instead of a list of repositories, there are no repositories associated with
your AWS account. To create a repository, see the section called “Create a Repository” (p. 76) or
follow the steps in the Git with AWS CodeCommit Tutorial (p. 58) tutorial.
4. Copy the SSH URL to use when connecting to the repository.
5. Open a terminal. From the /tmp directory, using the SSH URL you copied, run the git clone
command to clone the repository. For example, to clone a repository named MyDemoRepo to a local
repo named my-demo-repo in the US East (Ohio) region:
Note
If you successfully tested your connection, but the clone command fails, you might not have
the necessary access to your config file, or another setting might be in conflict with your
config file. Try connecting again, this time including the SSH key ID in the command. For
example:
For more information, see Access Error: Public Key Is Uploaded Successfully to IAM but
Connection Fails on Linux, macOS, or Unix Systems (p. 229).
For more information about how to connect to repositories, see Connect to the AWS CodeCommit
Repository by Cloning the Repository (p. 79).
Next Steps
You have completed the prerequisites. Follow the steps in AWS CodeCommit Tutorial (p. 43) to start
using AWS CodeCommit.
Topics
• Step 1: Initial Configuration for AWS CodeCommit (p. 30)
• Step 2: Install Git (p. 30)
• SSH and Windows: Set Up the Public and Private Keys for Git and AWS CodeCommit (p. 31)
• Step 4: Connect to the AWS CodeCommit Console and Clone the Repository (p. 33)
• Next Steps (p. 33)
After you have selected the policy you want to attach, choose Next: Review to review the list of
policies that will be attached to the IAM user. If the list is correct, choose Add permissions.
For more information about AWS CodeCommit managed policies and sharing access to repositories
with other groups and users, see Share a Repository (p. 81) and Authentication and Access
Control for AWS CodeCommit (p. 243).
Note
If you want to use AWS CLI commands with AWS CodeCommit, install the AWS CLI. For more
information, see Command Line Reference (p. 289).
If the version of Git you installed does not include a Bash emulator, such as Git Bash, install one. You will
use this emulator instead of the Windows command line when you configure SSH connections.
From the emulator, run the ssh-keygen command, and follow the directions to save the file to
the .ssh directory for your profile.
For example:
$ ssh-keygen
Enter passphrase (empty for no passphrase): <Type a passphrase, and then press Enter>
Enter same passphrase again: <Type the passphrase again, and then press Enter>
This generates:
cd .ssh
notepad codecommit_rsa.pub
Copy the contents of the file, and then close Notepad without saving. The contents of the file will
look similar to the following:
ssh-rsa EXAMPLE-AfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMCVVMxCzAJB
gNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb2
5zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhc
NMTEwNDI1MjA0NTIxWhcNMTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAw
DgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDAS=EXAMPLE user-name@computer-name
3. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
4. In the IAM console, in the navigation pane, choose Users, and from the list of users, choose your IAM
user.
5. On the user details page, choose the Security Credentials tab, and then choose Upload SSH public
key.
6. Paste the contents of your SSH public key into the field, and then choose Upload SSH public key.
7. Copy or save the information in SSH Key ID (for example, APKAEIBAERJR2EXAMPLE).
8. In the Bash emulator, type the following commands to create a config file in the ~/.ssh directory, or
edit it if one already exists:
notepad ~/.ssh/config
9. Add the following lines to the file, where the value for User is the SSH key ID you copied earlier, and
the value for IdentityFile is the path to and name of the private key file:
Host git-codecommit.*.amazonaws.com
User APKAEIBAERJR2EXAMPLE
IdentityFile ~/.ssh/codecommit_rsa
Note
If you gave your private key file a name other than codecommit_rsa, be sure to use it
here.
Save the file as config (not config.txt), and then close Notepad.
Important
The name of the file must be config with no file extension, or the SSH connections will
fail.
10. Run the following command to test your SSH configuration:
ssh git-codecommit.us-east-2.amazonaws.com
After you have confirmed the connection, you should see confirmation that you have added the
server to your known hosts file and a successful connection message. If you do not see a success
message, double-check that you saved the config file in the ~/.ssh directory of the IAM user
you configured for access to AWS CodeCommit, that the config file has no file extension (for
example, it must not be named config.txt), and that you specified the correct private key file
(codecommit_rsa, not codecommit_rsa.pub).
API Version 2015-04-13
32
AWS CodeCommit User Guide
Step 4: Connect to the AWS CodeCommit
Console and Clone the Repository
For information to help you troubleshoot problems, run the ssh command with the -v parameter:
ssh -v git-codecommit.us-east-2.amazonaws.com
You can find more information to help you troubleshoot connection problems in
Troubleshooting (p. 228).
If you see a Welcome page instead of a list of repositories, there are no repositories associated with
your AWS account. To create a repository, see the section called “Create a Repository” (p. 76) or
follow the steps in the Git with AWS CodeCommit Tutorial (p. 58) tutorial.
4. Choose Clone URL, and then copy the SSH URL.
5. In the Bash emulator, using the SSH URL you just copied, run the git clone command to clone the
repository. This command will create the local repo in a subdirectory of the directory where you run
the command. For example, to clone a repository named MyDemoRepo to a local repo named my-
demo-repo in the US East (Ohio) region:
Alternatively, open a command prompt, and using the URL and the SSH key ID for the public key you
uploaded to IAM, run the git clone command. The local repo will be created in a subdirectory of the
directory where you run the command. For example, to clone a repository named MyDemoRepo to a
local repo named my-demo-repo:
For more information, see Connect to the AWS CodeCommit Repository by Cloning the
Repository (p. 79) and Create a Commit (p. 161).
Next Steps
You have completed the prerequisites. Follow the steps in AWS CodeCommit Tutorial (p. 43) to start
using AWS CodeCommit.
Topics
• Step 1: Initial Configuration for AWS CodeCommit (p. 34)
• Step 2: Install Git (p. 36)
• Step 3: Set Up the Credential Helper (p. 36)
• Step 4: Connect to the AWS CodeCommit Console and Clone the Repository (p. 37)
• Next Steps (p. 38)
After you have selected the policy you want to attach, choose Next: Review to review the list of
policies that will be attached to the IAM user. If the list is correct, choose Add permissions.
For more information about AWS CodeCommit managed policies and sharing access to repositories
with other groups and users, see Share a Repository (p. 81) and Authentication and Access
Control for AWS CodeCommit (p. 243).
1. On your local machine, download and install the AWS CLI. This is a prerequisite for interacting with
AWS CodeCommit from the command line. For more information, see Getting Set Up with the AWS
Command Line Interface.
Note
AWS CodeCommit works only with AWS CLI versions 1.7.38 and later. To determine which
version of the AWS CLI you have installed, run the aws --version command.
To upgrade an older version of the AWS CLI to the latest version, see Installing the AWS
Command Line Interface.
2. Run this command to verify the AWS CodeCommit commands for the AWS CLI are installed:
aws configure
When prompted, specify the AWS access key and AWS secret access key of the IAM user you will use
with AWS CodeCommit. Also, be sure to specify the region where the repository exists, such as us-
east-2. When prompted for the default output format, specify json. For example:
AWS Access Key ID [None]: Type your target AWS access key ID here, and then press Enter
AWS Secret Access Key [None]: Type your target AWS secret access key here, and then
press Enter
Default region name [None]: Type a supported region for AWS CodeCommit here, and then
press Enter
Default output format [None]: Type json here, and then press Enter
To connect to a repository or a resource in another region, you must re-configure the AWS CLI with
the default region name for that region. Supported default region names for AWS CodeCommit
include:
• us-east-2
• us-east-1
• eu-west-1
• us-west-2
• ap-northeast-1
• ap-southeast-1
• ap-southeast-2
• eu-central-1
• ap-northeast-2
• sa-east-1
• us-west-1
• eu-west-2
• ap-south-1
• ca-central-1
For more information about AWS CodeCommit and regions, see Regions and Git Connection
Endpoints (p. 272). For more information about IAM, access keys, and secret keys, see How Do I Get
Credentials? and Managing Access Keys for IAM Users.
Tip
The credential helper will use the default AWS credential profile or the Amazon EC2
instance role. You can specify a profile to use, such as CodeCommitProfile, if you have
created a specific AWS credential profile to use with AWS CodeCommit:
If your profile name contains spaces, make sure you enclose the name in quotation marks
(").
You can configure profiles per repository instead of globally by using --local instead of
--global.
[credential]
helper = !aws --profile CodeCommitProfile codecommit credential-helper $@
UseHttpPath = true
Important
If you want to use a different IAM user on the same local machine for AWS CodeCommit,
you must run the git config command again and specify a different AWS credential profile.
2. Run git config --global --edit to verify the preceding value has been written to ~/.gitconfig. If
successful, you should see the preceding value (in addition to values that may already exist in the Git
global configuration file). To exit, typically you would type :q, and then press Enter.
If you experience problems after you configure your credential helper, see
Troubleshooting (p. 228).
Important
If you are using macOS, use the following steps to ensure the credential helper is configured
correctly.
3. If you are using macOS, use HTTPS to connect to an AWS CodeCommit repository (p. 78). After
you connect to an AWS CodeCommit repository with HTTPS for the first time, subsequent access
will fail after about fifteen minutes. The default Git version on macOS uses the Keychain Access
utility to store credentials. For security measures, the password generated for access to your AWS
CodeCommit repository is temporary, so the credentials stored in the keychain will stop working
after about 15 minutes. To prevent these expired credentials from being used, you must either:
• Install a version of Git that does not use the keychain by default.
• Configure the Keychain Access utility to not provide credentials for AWS CodeCommit repositories.
1. Open the Keychain Access utility. (You can use Finder to locate it.)
2. Search for git-codecommit.us-east-2.amazonaws.com. Highlight the row, open the context
menu or right-click it, and then choose Get Info.
3. Choose the Access Control tab.
4. In Confirm before allowing access, choose git-credential-osxkeychain, and then choose
the minus sign to remove it from the list.
Note
After removing git-credential-osxkeychain from the list, you will see a pop-up
dialog whenever you run a Git command. Choose Deny to continue. If you find the pop-
ups too disruptive, here are some alternate options:
• Connect to AWS CodeCommit using SSH instead of HTTPS. For more information, see
For SSH Connections on Linux, macOS, or Unix (p. 25).
• In the Keychain Access utility, on the Access Control tab for git-codecommit.us-
east-2.amazonaws.com, choose the Allow all applications to access this item
(access to this item is not restricted) option. This will prevent the pop-ups, but the
credentials will eventually expire (on average, this takes about 15 minutes) and you
will see a 403 error message. When this happens, you must delete the keychain item in
order to restore functionality.
• Install a version of Git that does not use the keychain by default.
If you see a Welcome page instead of a list of repositories, there are no repositories associated with
your AWS account. To create a repository, see the section called “Create a Repository” (p. 76) or
follow the steps in the Git with AWS CodeCommit Tutorial (p. 58) tutorial.
For more information, see Connect to the AWS CodeCommit Repository by Cloning the
Repository (p. 79) and Create a Commit (p. 161).
Next Steps
You have completed the prerequisites. Follow the steps in AWS CodeCommit Tutorial (p. 43) to start
using AWS CodeCommit.
This topic walks you through the steps to install the AWS CLI, set up your computer and AWS profile,
connect to an AWS CodeCommit repository, and clone that repository to your computer, also known as
creating a local repo. If you're new to Git, you might also want to review the information in Where Can I
Learn More About Git? (p. 3).
Topics
• Step 1: Initial Configuration for AWS CodeCommit (p. 38)
• Step 2: Install Git (p. 40)
• Step 3: Set Up the Credential Helper (p. 40)
• Step 4: Connect to the AWS CodeCommit Console and Clone the Repository (p. 42)
• Next Steps (p. 42)
2. Create an IAM user, or use an existing one, in your AWS account. Make sure you have an access key
ID and a secret access key associated with that IAM user. For more information, see Creating an IAM
User in Your AWS Account.
Note
AWS CodeCommit requires AWS Key Management Service. If you are using an existing
IAM user, make sure there are no policies attached to the user that expressly deny the
AWS KMS actions required by AWS CodeCommit. For more information, see AWS KMS and
Encryption (p. 282).
3. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
4. In the IAM console, in the navigation pane, choose Users, and then choose the IAM user you want to
configure for AWS CodeCommit access.
5. On the Permissions tab, choose Add Permissions.
6. In Grant permissions, choose Attach existing policies directly.
7. Select AWSCodeCommitFullAccess from the list of policies, or another managed policy for AWS
CodeCommit access. For more information about managed policies for AWS CodeCommit, see AWS
Managed (Predefined) Policies for AWS CodeCommit (p. 251).
After you have selected the policy you want to attach, choose Next: Review to review the list of
policies that will be attached to the IAM user. If the list is correct, choose Add permissions.
For more information about AWS CodeCommit managed policies and sharing access to repositories
with other groups and users, see Share a Repository (p. 81) and Authentication and Access
Control for AWS CodeCommit (p. 243).
1. On your local machine, download and install the AWS CLI. This is a prerequisite for interacting with
AWS CodeCommit from the command line. For more information, see Getting Set Up with the AWS
Command Line Interface.
Note
AWS CodeCommit works only with AWS CLI versions 1.7.38 and later. To determine which
version of the AWS CLI you have installed, run the aws --version command.
To upgrade an older version of the AWS CLI to the latest version, see Installing the AWS
Command Line Interface.
2. Run this command to verify the AWS CodeCommit commands for the AWS CLI are installed:
aws configure
When prompted, specify the AWS access key and AWS secret access key of the IAM user you will use
with AWS CodeCommit. Also, be sure to specify the region where the repository exists, such as us-
east-2. When prompted for the default output format, specify json. For example:
AWS Access Key ID [None]: Type your target AWS access key ID here, and then press Enter
AWS Secret Access Key [None]: Type your target AWS secret access key here, and then
press Enter
Default region name [None]: Type a supported region for AWS CodeCommit here, and then
press Enter
Default output format [None]: Type json here, and then press Enter
To connect to a repository or a resource in another region, you must re-configure the AWS CLI with
the default region name for that region. Supported default region names for AWS CodeCommit
include:
• us-east-2
• us-east-1
• eu-west-1
• us-west-2
• ap-northeast-1
• ap-southeast-1
• ap-southeast-2
• eu-central-1
• ap-northeast-2
• sa-east-1
• us-west-1
• eu-west-2
• ap-south-1
• ca-central-1
For more information about AWS CodeCommit and regions, see Regions and Git Connection
Endpoints (p. 272). For more information about IAM, access keys, and secret keys, see How Do I Get
Credentials? and Managing Access Keys for IAM Users.
To install Git, we recommend websites such as Git for Windows. If you use this link to install Git, you can
accept all of the installation default settings except for the following:
• When prompted during the Adjusting your PATH environment step, select the Use Git from the
Windows Command Prompt option.
• (Optional) If you intend to use HTTPS with the credential helper that is included in the AWS CLI
instead of configuring Git credentials for AWS CodeCommit, on the Configuring extra options page,
make sure the Enable Git Credential Manager option is cleared. The Git Credential Manager is only
compatible with AWS CodeCommit if IAM users configure Git credentials. For more information, see
For HTTPS Users Using Git Credentials (p. 5) and Git for Windows: I Installed Git for Windows, but I
Am Denied Access to My Repository (403) (p. 235).
Note
Git is an evolving, regularly updated platform. Occasionally, a feature change might affect the
way it works with AWS CodeCommit. If you encounter issues with a specific version of Git and
AWS CodeCommit, review the information in Troubleshooting (p. 228).
AWS secret access key (along with a default region name and default output format). The Git credential
helper uses this information to automatically authenticate with AWS CodeCommit so you don't need to
type this information every time you use Git to interact with AWS CodeCommit.
1. Open a command prompt and use Git to run git config, specifying the use of the Git credential
helper with the AWS credential profile, which enables the Git credential helper to send the path to
repositories:
The Git credential helper writes the following to the .gitconfig file:
[credential]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
Important
• If you are using a Bash emulator instead of the Windows command line, you must use
single quotes instead of double quotes.
• The credential helper will use the default AWS profile or the Amazon EC2 instance role. If
you have created an AWS credential profile to use, such as CodeCommitProfile, you can
modify the command as follows to use it instead:
[credential]
helper = !aws codecommit credential-helper --profile=CodeCommitProfile $@
UseHttpPath = true
• If your profile name contains spaces, you must edit your .gitconfig file after you run this
command to enclose it in single quotes ('); otherwise, the credential helper will not work.
• If your installation of Git for Windows included the Git Credential Manager utility, you
will see 403 errors or prompts to provide credentials into the Credential Manager utility
after the first few connection attempts. The most reliable way to solve this problem is
to uninstall and then reinstall Git for Windows without the option for the Git Credential
Manager utility, as it is not compatible with AWS CodeCommit. If you want to keep the
Git Credential Manager utility, you must perform additional configuration steps to also
use AWS CodeCommit, including manually modifying the .gitconfig file to specify the use
of the credential helper for AWS CodeCommit when connecting to AWS CodeCommit.
Remove any stored credentials from the Credential Manager utility (you can find this
utility in Control Panel). Once you have removed any stored credentials, add the following
to your .gitconfig file, save it, and then try connecting again from a new command
prompt window:
[credential "https://git-codecommit.us-east-2.amazonaws.com"]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
[credential "https://git-codecommit.us-east-1.amazonaws.com"]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
API Version 2015-04-13
41
AWS CodeCommit User Guide
Step 4: Connect to the AWS CodeCommit
Console and Clone the Repository
Additionally, you might have to re-configure your git config settings by specifying --
system instead of --global or --local before all connections work as expected.
• If you want to use different IAM users on the same local machine for AWS CodeCommit,
you should specify git config --local instead of git config --global, and run the
configuration for each AWS credential profile.
2. Run git config --global --edit to verify the preceding values have been written to
the .gitconfig file for your user profile (by default, %HOME%\.gitconfig or drive:\Users
\UserName\.gitconfig). If successful, you should see the preceding values (in addition to values
that may already exist in the Git global configuration file). To exit, typically you would type :q and
then press Enter.
If you see a Welcome page instead of a list of repositories, there are no repositories associated with
your AWS account. To create a repository, see the section called “Create a Repository” (p. 76) or
follow the steps in the Git with AWS CodeCommit Tutorial (p. 58) tutorial.
4. Copy the HTTPS URL to use when connecting to the repository.
5. Open a command prompt and use the URL to clone the repository with the git clone command.
The local repo will be created in a subdirectory of the directory where you run the command. For
example, to clone a repository named MyDemoRepo to a local repo named my-demo-repo in the US
East (Ohio) region:
On some versions of Windows, you might see a pop-up dialog box asking for your user name and
password. This is the built-in credential management system for Windows, but it is not compatible
with the credential helper for AWS CodeCommit. Choose Cancel.
For more information about how to connect to repositories, see Connect to the AWS CodeCommit
Repository by Cloning the Repository (p. 79).
Next Steps
You have completed the prerequisites. Follow the steps in AWS CodeCommit Tutorial (p. 43) to start
using AWS CodeCommit.
You can also follow the tutorial in Simple Pipeline Walkthrough with AWS CodePipeline and AWS
CodeCommit to learn how to use your AWS CodeCommit repository as part of a continuous delivery
pipeline.
The tutorials in this section assume you have completed the prerequisites and setup (p. 4), including:
Topics
• Getting Started with AWS CodeCommit Tutorial (p. 43)
• Git with AWS CodeCommit Tutorial (p. 58)
The AWS CodeCommit console includes helpful information in a collapsible panel that you can open
from the information icon or any “Info” link on the page. ( ). You can close this panel at any time.
If you are not familiar with Git, you might want to complete the Git with AWS CodeCommit
Tutorial (p. 58) in addition to this tutorial. After you finish this tutorial, you should have enough
practice to start using AWS CodeCommit for your own projects and in team environments.
Important
Before you begin, you must complete the prerequisites and setup (p. 4), including:
Topics
• Step 1: Create an AWS CodeCommit Repository (p. 45)
• Step 2: Add Files to Your Repository (p. 46)
• Step 3: Browse the Contents of Your Repository (p. 48)
• Step 4: Create and Collaborate on a Pull Request (p. 54)
• Step 5: Next Steps (p. 58)
• Step 6: Clean Up (p. 58)
Note
If you use a name other than MyDemoRepo for your repository, be sure to use it in the remaining
steps of this tutorial.
When the repository opens, you see information about how to add files directly from the AWS
CodeCommit console.
The simplest way to get started is to add a file from the AWS CodeCommit console.
3. Do the following:
• If you want to add the file to a different branch, from the drop-down list of branches, choose the
branch where you want to add the file. The default branch is selected automatically for you. In the
example shown here, the default branch is named master.
• In Author name, enter the name you want displayed to other repository users.
• In Email address, enter an email address.
• (Optional) In Commit message, enter a brief message. Although this is optional, we recommend
you add a commit message to help your team members understand why you added this file. If you
do not enter a commit message, a default message is used.
• If you're uploading a file, choose the file you want to upload.
• If you're creating a file, in File name, enter a name for the file, and then in the code editor, enter
the code you want to add.
For more information, see Working with Files in AWS CodeCommit Repositories (p. 129).
To use a Git client to clone the repository, install Git on your local computer, and then clone the AWS
CodeCommit repository. Add some files to the local repo and push them to the AWS CodeCommit
repository. For an in-depth introduction, try the Git with AWS CodeCommit Tutorial (p. 58). If you
are familiar with Git, but are not sure how to do this with an AWS CodeCommit repository, you can
view examples and instructions in Create a Commit (p. 161), Step 2: Create a Local Repo (p. 60), or
Connect to a Repository (p. 78).
After you have added some files to the AWS CodeCommit repository, you can view them in the console.
3. To view the contents of a file in your repository, choose the file from the list. Choose the gear icon to
change the color display option of the displayed code.
You can also browse the commit history of a repository. This helps you identify changes made in a
repository, including when and by whom those changes were made.
1. In the navigation pane for a repository, choose Commits. A history of commits for the repository in
the default branch is displayed, in reverse chronological order.
2. Review the commit history by branch (p. 190) or by tag (p. 186), and get details about commits
by author, date, and more.
3. To view the differences between a commit and its parent, choose the abbreviated commit ID. You
can choose how the changes are displayed, including showing or hiding white space changes, and
whether to view changes inline (Unified view) or side by side (Split view).
Note
Your preferences for viewing code and other console settings are saved as browser
cookies whenever you change them. For more information, see Working with User
Preferences (p. 204).
4. To view all comments on a commit, choose the commit and then scroll through the changes to view
them inline. You can also add your own comments and reply to the comments made by others.
For more information, see Browse the Commit History of a Repository (p. 163) and Compare
Commits (p. 170).
6. In Commits, choose the Commit visualizer tab.
The commit graph is displayed, with the subject line for each commit shown next to its point in the
graph. The subject line display is limited to 80 characters.
7. To see more details about a commit, choose its abbreviated commit ID. To render the graph from
a specific commit, choose that point in the graph. For more information, see View a Graph of the
Commit History of a Repository (p. 164).
If you set up notifications for your repository, repository users can receive emails about repository
events (for example, for pull requests or when someone comments on code). For more information, see
Configuring Notifications for Events in an AWS CodeCommit Repository (p. 84).
In Create pull request, in Source, choose the branch that contains the changes you want reviewed.
In Destination, choose the branch where you want the reviewed code to be merged when the pull
request is closed. Choose Compare.
3. Review the merge details and changes to confirm that the pull request contains the changes and
commits you want reviewed. If so, in Title, enter a title for this review. This is the title that appears
in the list of pull requests for the repository. In Description, enter details about what this review is
about and any other useful information for reviewers. Choose Create.
4. Your pull request appears in the list of pull requests for the repository. You can filter the view to
show only open requests, closed requests, requests that you created, and more.
5. If you configured notifications for your repository and chose to notify users of pull request events,
users receive email about your new pull request. Users can view the changes and comment on
specific lines of code, files, and the pull request itself. They can also reply to comments. If necessary,
you can push changes to the pull request branch, which updates the pull request.
6. When you are satisfied that all the code changes have been reviewed and agreed to, from the pull
request, do one of the following:
• If you want to use the fast-forward merge option to automatically merge the branches as part of
closing the pull request, choose Merge.
• If you want to close the pull request without using the automatic fast-forward merge option to
merge branches, choose Close pull request.
• If there are merge conflicts in the branches that cannot be automatically resolved, use your local
Git client to merge the branches and then push the merge. This closes the pull request.
Note
You can always manually merge branches, including pull request branches, by using the git
merge command in your local repo and pushing your changes. AWS CodeCommit closes the
pull request when you push the merged code.
For more information, see Working with Pull Requests (p. 138).
• If you are new to Git and AWS CodeCommit or want to review examples of using Git with AWS
CodeCommit, continue to the Git with AWS CodeCommit Tutorial (p. 58) tutorial.
• If you want to work with others in an AWS CodeCommit repository, see Share a Repository (p. 81).
(If you want to share your repository with users in another AWS account, see Configure Cross-Account
Access to an AWS CodeCommit Repository (p. 118).)
• If you want to migrate a repository to AWS CodeCommit, follow the steps in Migrate to AWS
CodeCommit (p. 205).
• If you want to add your repository to a continuous delivery pipeline, follow the steps in Simple
Pipeline Walkthrough.
• If you want to learn more about products and services that integrate with AWS CodeCommit, including
examples from the community, see Product and Service Integrations (p. 68).
Step 6: Clean Up
If you are done with exploring AWS CodeCommit and no longer need the repository, you should delete
the AWS CodeCommit repository and other resources you used in this tutorial so you won't continue to
be charged for the storage space.
Important
After you delete this repository, you can no longer clone it to any local repo or shared repo. You
also can no longer pull data from it, push data to it, or perform any Git operations, from any
local repo or shared repo. This action cannot be undone.
If you configured notifications for your repository, deleting the repository also deletes the
Amazon CloudWatch Events rule created for the repository. It does not delete the Amazon SNS
topic used as a target for that rule.
If you configured triggers for your repository, deleting the repository does not delete the
Amazon SNS topics or Lambda functions you configured as the targets of those triggers. Be
sure to delete those resources if you don't need them. For more information, see Delete Triggers
from a Repository (p. 106).
In this tutorial, you create a repository that represents a local copy of the AWS CodeCommit repository,
which we refer to here and in the rest of the documentation as a local repo.
After you create the local repo, you make some changes to it. Then you send (push) your changes to the
AWS CodeCommit repository.
You also simulate a team environment where two users independently commit changes to their local
repo and push those changes to the AWS CodeCommit repository. The users then pull the changes from
the AWS CodeCommit repository to their own local repo to see the changes the other user made.
You also create branches and tags and manage some access permissions in the AWS CodeCommit
repository.
After you complete this tutorial, you should have enough practice with the core Git and AWS
CodeCommit concepts to use them for your own projects.
Topics
• Step 1: Create an AWS CodeCommit Repository (p. 59)
• Step 2: Create a Local Repo (p. 60)
• Step 3: Create Your First Commit (p. 60)
• Step 4: Push Your First Commit (p. 61)
• Step 5: Share the AWS CodeCommit Repository and Push and Pull Another Commit (p. 61)
• Step 6: Create and Share a Branch (p. 63)
• Step 7: Create and Share a Tag (p. 64)
• Step 8: Set Up Access Permissions (p. 65)
• Step 9: Clean Up (p. 66)
You can skip this step if you already have an AWS CodeCommit repository you want to use.
Note
Depending on your usage, you might be charged for creating or accessing a repository. For more
information, see Pricing on the AWS CodeCommit product information page.
Note
The remaining steps in this tutorial use MyDemoRepo for the name of your AWS CodeCommit
repository. If you choose a different name, be sure to use it throughout this tutorial.
For more information about creating repositories, including how to create a repository from the terminal
or command line, see Create a Repository (p. 76).
1. Use a text editor to create the following two example text files in your directory. Name the files
cat.txt and dog.txt:
cat.txt
-------
The domestic cat (Felis catus or Felis silvestris catus) is a small, usually furry,
domesticated, and carnivorous mammal.
dog.txt
-------
The domestic dog (Canis lupus familiaris) is a canid that is known as man's best
friend.
Tip
To see details about the commit you just made, run git log.
Run git push to push your commit through the default remote name Git uses for your AWS CodeCommit
repository (origin), from the default branch in your local repo (master):
Tip
After you have pushed files to your AWS CodeCommit repository, you can use the AWS
CodeCommit console to view the contents. For more information, see Browse Files in a
Repository (p. 130).
In this tutorial, you simulate the fellow user by having Git create a directory separate from the one you
created in step 2 (p. 60). (Typically, this directory would be on a different machine.) This new directory
is a copy of your AWS CodeCommit repository. Any changes you make to the existing directory or this
new directory are made independently. The only way to identify changes to these directories is to pull
from the AWS CodeCommit repository.
Even though they're on the same local machine, we call the existing directory your local repo and the
new directory the shared repo.
From the new directory, you get a separate copy of the AWS CodeCommit repository. You then add a
new example file, commit the changes to the shared repo, and then push the commit from the shared
repo to your AWS CodeCommit repository.
Lastly, you pull the changes from your repository to your local repo and then browse it to see the
changes committed by the other user.
For HTTPS:
For SSH:
Note
When you clone a repository using SSH on Windows operating systems, you must add the
SSH key ID to the connection string as follows:
For more information, see For SSH Connections on Windows (p. 29).
In this command, MyDemoRepo is the name of your AWS CodeCommit repository. shared-demo-
repo is the name of the directory Git creates in the /tmp directory or the c:\temp directory. After
Git creates the directory, Git pulls down a copy of your repository into the shared-demo-repo
directory.
3. Switch to the shared-demo-repo directory:
4. Run git config to add another user name and email address represented by placeholders other-
user-name and other-email-address (for example, John Doe and [email protected]).
This makes it easier to identify the commits the other user made:
5. Use a text editor to create the following example text file in the shared-demo-repo directory.
Name the file horse.txt:
horse.txt
-------
The horse (Equus ferus caballus) is one of two extant subspecies of Equus ferus.
8. Run git push to push your initial commit through the default remote name Git uses for your AWS
CodeCommit repository (origin), from the default branch in your local repo (master):
9. Switch to your local repo and run git pull to pull into your local repo the commit the shared repo
made to the AWS CodeCommit repository. Then run git log to see the commit that was initiated
from the shared repo.
A branch allows you to independently develop a different version of the repository's contents (for
example, to work on a new software feature without affecting the work of your team members). When
that feature is stable, you merge the branch into a more stable branch of the software.
You use Git to create the branch and then point it to the first commit you made. You use Git to push the
branch to the AWS CodeCommit repository. You then switch to your shared repo and use Git to pull the
new branch into your shared local repo and explore the branch.
1. From your local repo, run git checkout, specifying the name of the branch (for example,
MyNewBranch) and the ID of the first commit you made in the local repo.
If you don't know the commit ID, run git log to get it. Make sure the commit has your user name
and email address, not the user name and email address of the other user. This is to simulate that
master is a stable version of the AWS CodeCommit repository and the MyNewBranch branch is for
some new, relatively unstable feature:
2. Run git push to send the new branch from the local repo to the AWS CodeCommit repository:
3. Now, pull the branch into the shared repo and check your results:
4. Switch back to the master branch and view its list of commits. The Git commands should look like
this:
5. Switch to the master branch in your local repo. You can run git status or git branch. The output
shows which branch you are on. In this case, it should be master. The Git commands should look
like this:
A tag is used to give a human-readable name to a commit (or branch or even another tag). You would do
this, for example, if you want to tag a commit as "v2.1." A commit, branch, or tag can have any number
of tags associated with it, but an individual tag can be associated with only one commit, branch, or tag.
In this tutorial, you tag one commit as release and one as beta.
You use Git to create the new tags, pointing the release tag to the first commit you made and the beta
tag to the commit made by the other user. You then use Git to push the tags to the AWS CodeCommit
repository. Then you switch to your shared repo and use Git to pull the tags into your shared local repo
and explore the tags.
1. From your local repo, run git tag, specifying the name of the new tag (release) and the ID of the
first commit you made in the local repo.
If you don't know the commit ID, run git log to get it. Make sure the commit has your user name and
email address, not the user name and email address of the other user. This is to simulate that your
commit is a stable version of the AWS CodeCommit repository:
Run git tag again to tag the commit from the other user with the beta tag. This is to simulate that
the commit is for some new, relatively unstable feature:
2. Run git push --tags to send the tags to the AWS CodeCommit repository.
3. Now pull the tags into the shared repo and check your results:
To do this, you use the IAM console to create an IAM user, who, by default, does not have permissions to
synchronize the shared repo with the AWS CodeCommit repository. You can run git pull to verify this.
If the new user doesn't have permission to synchronize, the command doesn't work. Then you go back
to the IAM console and apply a policy that allows the user to use git pull. Again, you can run git pull to
verify this.
This step assumes you have permissions to create IAM users in your AWS account. If you don't have these
permissions, then you can't perform the procedures in this step. Skip ahead to Step 9: Clean Up (p. 66)
to clean up the resources you used for your tutorial.
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
Be sure to sign in with the same user name and password you used in Setting Up (p. 4).
2. In the navigation pane, choose Users, and then choose Create New Users.
3. In the first Enter User Names box, type an example user name (for example, JaneDoe-
CodeCommit). Select the Generate an access key for each user box, and choose Create.
4. Choose Show User Security Credentials. Make a note of the access key ID and secret access key or
choose Download Credentials.
5. Follow the instructions in For HTTPS Users Using Git Credentials (p. 5) to generate and supply the
credentials of the IAM user.
If you want to use SSH, follow the instructions in SSH and Linux, macOS, or Unix: Set Up the Public
and Private Keys for Git and AWS CodeCommit (p. 26) or SSH and Windows: Set Up the Public and
Private Keys for Git and AWS CodeCommit (p. 31) to set up the user with public and private keys.
6. Run git pull. The following error should appear:
For HTTPS:
For SSH:
The error appears because the new user doesn't have permission to synchronize the shared repo
with the AWS CodeCommit repository.
7. Return to the IAM console. In the navigation pane, choose Policies, and then choose Create Policy.
(If a Get Started button appears, choose it, and then choose Create Policy.)
8. Next to Create Your Own Policy, choose Select.
9. In the Policy Name box, type a name (for example, CodeCommitAccess-GettingStarted).
10. In the Policy Document box, type the following, which allows an IAM user to pull from any
repository associated with the IAM user:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:GitPull"
],
"Resource": "*"
}
]
}
Tip
If you want the IAM user to be able to push commits to any repository associated with the
IAM user, type this instead:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:GitPull",
"codecommit:GitPush"
],
"Resource": "*"
}
]
}
For information about other AWS CodeCommit action and resource permissions you can
give to users, see Authentication and Access Control for AWS CodeCommit (p. 243).
11. In the navigation pane, choose Users.
12. Choose the example user name (for example, JaneDoe-CodeCommit) to which you want to attach
the policy.
13. Choose the Permissions tab.
14. In Managed Policies, choose Attach Policy.
15. Select the CodeCommitAccess-GettingStarted policy you just created, and then choose Attach
Policy.
16. Run git pull. This time the command should work and an Already up-to-date message should
appear.
17. If you are using HTTPS, switch to your original credentials. For more information, see the
instructions in Step 3: Set Up the Credential Helper (p. 36) or Step 3: Set Up the Credential
Helper (p. 40).
If you are using SSH, switch to your original keys. For more information, see SSH and Linux, macOS,
or Unix: Set Up the Public and Private Keys for Git and AWS CodeCommit (p. 26) or SSH and
Windows: Set Up the Public and Private Keys for Git and AWS CodeCommit (p. 31).
Step 9: Clean Up
In this step, you delete the AWS CodeCommit repository you used in this tutorial, so you won't continue
to be charged for the storage space.
You also remove the local repo and shared repo on your local machine because they won't be needed
after you delete the AWS CodeCommit repository.
Important
After you delete this repository, you won't be able to clone it to any local repo or shared repo.
You also won't be able to pull data from it, or push data to it, from any local repo or shared
repo. This action cannot be undone.
cd /tmp
rm -rf /tmp/my-demo-repo
rm -rf /tmp/shared-demo-repo
For Windows:
cd c:\temp
rd /s /q c:\temp\my-demo-repo
rd /s /q c:\temp\shared-demo-repo
Topics
• Integration with Other AWS Services (p. 68)
• Integration Examples from the Community (p. 72)
Learn more:
Learn more:
Learn more:
Learn more:
Learn more:
• Plan a Build
• Create a Build Project
• Use AWS CodePipeline with AWS CodeBuild to
Run Builds
Learn more:
Learn more:
Learn more:
AWS Key Management Service AWS KMS is a managed service that makes it
easy for you to create and control the encryption
keys used to encrypt your data. By default,
AWS CodeCommit uses AWS KMS to encrypt
repositories.
Learn more:
Learn more:
Amazon Simple Notification Service Amazon SNS is a web service that enables
applications, end users, and devices to instantly
send and receive notifications from the cloud.
You can configure triggers for AWS CodeCommit
repositories that will send Amazon SNS
notifications in response to repository events.
You can also use Amazon SNS notifications to
integrate with other AWS services. For example,
you can use an Amazon SNS notification to send
messages to an Amazon Simple Queue Service
queue.
Learn more:
Topics
• Blog Posts (p. 72)
• Code Samples (p. 74)
Blog Posts
• Refining Access to Branches in AWS CodeCommit
Learn how to restrict commits to repository branches by creating and applying an IAM policy that uses
a context key.
Learn how to set up continuous replication of an AWS CodeCommit repository from one AWS region to
another using a serverless architecture.
Learn how to use AWS CodePipeline, AWS CodeCommit, AWS CodeBuild, and AWS Lambda to ensure
that cookbooks and other configurations are consistently deployed across two or more Chef Servers
residing in one or more AWS Regions.
• Peanut Butter and Chocolate: Azure Functions CI/CD Pipeline with AWS CodeCommit
Learn how to create a PowerShell-based Azure Functions CI/CD pipeline where the code is stored in an
AWS CodeCommit repository.
Learn how to use Kubernetes and AWS together to create a fully managed, continuous deployment
pipeline for container based applications.
Learn how to use pull requests to review, comment upon, and interactively iterate on code changes in
an AWS CodeCommit repository.
Learn how to create CloudWatch Events rules that process changes in a repository using AWS
CodeCommit repository events and target actions in other AWS services. Examples include
AWS Lambda functions that enforce Git commit message policies on commits, replicate an AWS
CodeCommit repository, and backing up an AWS CodeCommit repository to Amazon S3.
Learn how to back up or replicate an AWS CodeCommit repository to another AWS region, and how to
back up repositories hosted on other services to AWS CodeCommit.
Learn how to push code to two repositories as part of migrating from using another Git repository to
AWS CodeCommit when using SourceTree.
Learn how to create a continuous testing process for mobile devices using Appium, AWS CodeCommit,
Jenkins, and Device Farm.
Learn how to clone your AWS CodeCommit repository and, in one command, configure the credential
helper to use a specific IAM role for connections to that repository.
Learn how AWS OpsWorks can automatically fetch Apps and Chef cookbooks from AWS CodeCommit.
Learn how to configure your gitconfig file to work with both AWS CodeCommit and GitHub credential
helpers.
Learn how to use the EGit tools in Eclipse to work with AWS CodeCommit.
Learn how to use an instance profile for Amazon EC2 when configuring automated agent access to an
AWS CodeCommit repository.
Learn how to use AWS CodeCommit and Jenkins to support two simple continuous integration (CI)
scenarios.
Learn how to integrate AWS CodeCommit into a development workflow using the Review Board code
review system.
Code Samples
The following are code samples that might be of interest to AWS CodeCommit users.
If you use the credential helper for AWS CodeCommit on Mac OS X, you are likely familiar with the
problem with cached credentials. This script demonstrate one solution.
Before you can push changes to an AWS CodeCommit repository, you must configure your IAM user in
your AWS account. For more information, see Step 1: Initial Configuration for AWS CodeCommit (p. 6).
For information about working with other aspects of your repository in AWS CodeCommit, see Working
with Files (p. 129), Working with Pull Requests (p. 138) , Working with Commits (p. 160), Working
with Branches (p. 190), and Working with User Preferences (p. 204). To learn about migrating to AWS
CodeCommit, see Migrate to AWS CodeCommit (p. 205).
Topics
• Create an AWS CodeCommit Repository (p. 76)
• Connect to an AWS CodeCommit Repository (p. 78)
These instructions are written with the assumption that you have already completed the steps in Setting
Up (p. 4).
Note
Depending on your usage, you might be charged for creating or accessing a repository. For more
information, see Pricing on the AWS CodeCommit product information page.
Topics
• Create a Repository (Console) (p. 76)
• Create an AWS CodeCommit Repository (AWS CLI) (p. 77)
After you create a repository, you can connect to it and start adding code either through the AWS
CodeCommit console or a local Git client, or by integrating your AWS CodeCommit repository with your
favorite IDE. For more information, see Setting Up for AWS CodeCommit (p. 4). You can also add your
repository to a continuous delivery pipeline. For more information, see Simple Pipeline Walkthrough.
To get information about the new AWS CodeCommit repository, such as the URLs to use when cloning
the repository, choose the repository's name from the list, or just choose the connection protocol you
want to use next to the repository's name.
To share this repository with others, you must send them the HTTPS or SSH link to use to clone the
repository. Make sure they have the permissions required to access the repository. For more information,
see Share a Repository (p. 81) and Authentication and Access Control for AWS CodeCommit (p. 243).
1. Make sure that you have configured the AWS CLI with the region where the repository exists. To
verify the region, type the following command at the command line or terminal and review the
information for default region name:
aws configure
The default region name must match the region for the repository in AWS CodeCommit. For more
information, see Regions and Git Connection Endpoints (p. 272).
2. Run the create-repository command, specifying:
• A name that uniquely identifies the AWS CodeCommit repository (with the --repository-name
option).
Note
This name must be unique across an AWS account.
• Optionally, a comment about the AWS CodeCommit repository (with the --repository-
description option).
For example, to create an AWS CodeCommit repository named MyDemoRepo with the description
"My demonstration repository":
Note
The description field displays Markdown in the console and accepts all HTML characters
and valid Unicode characters. If you are an application developer who is using the
GetRepository or BatchGetRepositories APIs and you plan to display the repository
description field in a web browser, see the AWS CodeCommit API Reference.
3. If successful, this command outputs a repositoryMetadata object with the following information:
{
"repositoryMetadata": {
"repositoryName": "MyDemoRepo",
"repositoryDescription": "My demonstration repository",
"repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE",
"accountId": "creator-account-ID"
}
}
4. Make a note of the name and ID of the AWS CodeCommit repository. You need them to monitor and
change information about the AWS CodeCommit repository, especially if you use AWS CLI.
If you forget the name or ID, follow the instructions in View AWS CodeCommit Repository Details
(AWS CLI) (p. 110).
After you create a repository, you can connect to it and start adding code. For more information, see
Connect to a Repository (p. 78). You can also add your repository to a continuous delivery pipeline.
For more information, see Simple Pipeline Walkthrough.
Topics
• Prerequisites for Connecting to an AWS CodeCommit Repository (p. 78)
• Connect to the AWS CodeCommit Repository by Cloning the Repository (p. 79)
• Connect a Local Repo to the AWS CodeCommit Repository (p. 80)
• You must have configured your local computer with the software and settings required to connect to
AWS CodeCommit. For more information, see Setting Up (p. 4).
• You must have the clone URL of the AWS CodeCommit repository to which you want to connect.
This URL includes the name of the repository and its AWS region. For more information, see View
Repository Details (p. 108).
If you have not yet created an AWS CodeCommit repository, follow the instructions in Create a
Repository (p. 76), copy the clone URL of the new AWS CodeCommit repository, and return to this
page.
If you have an AWS CodeCommit repository but you do not know its name, follow the instructions in
View Repository Details (p. 108).
• You must have a location on your local machine to store a local copy of the AWS CodeCommit
repository you connect to. (This local copy of the AWS CodeCommit repository is known as a local
repo.) You then switch to and run Git commands from that location. For example, you could use /tmp
(for Linux, macOS, or Unix) or c:\temp (for Windows) if you are making a temporary clone for testing
purposes. That is the directory path used in these examples for demonstration purposes.
Note
You can use any directory you want. If you are cloning a repository for long-term use, consider
creating the clone from a working directory and not one used for temporary files. If you are
using a directory different from /tmp or c:\temp, be sure to substitute that directory for ours
when you follow these instructions.
For HTTPS:
For SSH:
For more information, see For SSH Connections on Windows (p. 29) and
Troubleshooting (p. 228).
After Git creates the directory, it pulls down a copy of your AWS CodeCommit repository into the
newly created directory.
If the AWS CodeCommit repository is new or otherwise empty, you see a message that you are
cloning an empty repository. This is expected.
API Version 2015-04-13
79
AWS CodeCommit User Guide
Connect a Local Repo to the AWS CodeCommit Repository
Note
If you receive an error that Git can't find the AWS CodeCommit repository or that you don't
have permission to connect to the AWS CodeCommit repository, make sure you completed
the prerequisites (p. 4), including assigning permissions to the IAM user and setting up your
IAM user credentials for Git and AWS CodeCommit on the local machine. Also, make sure
you specified the correct repository name.
After you successfully connect your local repo to your AWS CodeCommit repository, you are now ready to
start running Git commands from the local repo to create commits, branches, and tags and push to and
pull from the AWS CodeCommit repository.
For example, the following command adds the remote nicknamed origin to https://git-
codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo:
For HTTPS:
For SSH:
For HTTPS:
For SSH:
After you successfully connect your local repo to your AWS CodeCommit repository, you are ready to
start running Git commands from the local repo to create commits, branches, and tags, and to push to
and pull from the AWS CodeCommit repository.
These instructions are written with the assumption that you have already completed the steps in Setting
Up (p. 4) and Create a Repository (p. 76).
Note
Depending on your usage, you might be charged for creating or accessing a repository. For more
information, see Pricing on the AWS CodeCommit product information page.
Topics
• Choose the Connection Protocol to Share with Your Users (p. 81)
• Create IAM Policies for Your Repository (p. 82)
• Create an IAM Group for Repository Users (p. 83)
• Share the Connection Information with Your Users (p. 83)
• Git credentials, which IAM users can generate for themselves in IAM. Git credentials are the easiest
method for users of your repository to set up and use.
• An AWS access key, which your repository users must configure in the credential helper included in the
AWS CLI. (This is the only method available for root account or federated users.)
Because this is a more complex configuration process, we recommend that you choose HTTPS and Git
credentials for connections to AWS CodeCommit.
For more information about HTTPS, SSH, Git, and remote repositories, see Setting Up (p. 4) or
consult your Git documentation. For a general overview of communication protocols and how each
communicates with remote repositories, see Git on the Server - The Protocols.
Note
Although Git supports a variety of connection protocols, AWS CodeCommit does not support
connections with unsecured protocols, such as the local protocol or generic HTTP.
To review the contents of the policy and the other managed policies for AWS CodeCommit and learn
more about creating and applying permissions by using policies, see Authentication and Access Control
for AWS CodeCommit (p. 243).
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the Dashboard navigation area, choose Policies, and then choose Create Policy.
3. On the Create Policy page, next to Copy an AWS Managed Policy, choose Select.
4. On the Copy an AWS Managed Policy page, in Search Policies, enter AWSCodeCommitPowerUser.
Choose Select next to the policy name.
5. On the Review Policy page, in Policy Name, enter a new name for the policy (for example,
AWSCodeCommitPowerUser-MyDemoRepo).
In Policy Document, replace the "*" portion of the Resource line with the Amazon Resource Name
(ARN) of the AWS CodeCommit repository, as shown here:
"Resource": [
"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo"
]
Tip
To find the ARN for the AWS CodeCommit repository, go to the AWS CodeCommit console
and choose the repository name from the list. For more information, see View Repository
Details (p. 108).
If you want this policy to apply to more than one repository, add each repository as a resource by
specifying its ARN. Include a comma between each resource statement, as shown here:
"Resource": [
"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo",
"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyOtherDemoRepo"
]
6. Choose Validate Policy. After the policy is validated, choose Create Policy.
If you use SSH, you must attach another managed policy to the IAMUserSSHKeys group, the IAM
managed policy that allows users to upload their SSH public key and associate it with the IAM user they
use to connect to AWS CodeCommit.
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the Dashboard navigation area, choose Groups, and then choose Create New Group.
3. On the Set Group Name page, in Group Name, enter a name for the group (for example,
MyDemoRepoGroup), and then choose Next Step. Consider including the repository name as part of
the group name.
Note
This name must be unique across an AWS account.
4. Select the check box next to the customer managed policy you created in the previous section (for
example, AWSCodeCommitPowerUser-MyDemoRepo).
5. On the Review page, choose Create Group. IAM creates this group with the specified policies already
attached. The group appears in the list of groups associated with your AWS account.
6. Choose your group from the list.
7. On the group summary page, choose the Users tab, and then choose Add Users to Group. On the
list that shows all users associated with your AWS account, select the check boxes next to the users
to whom you want to allow access to the AWS CodeCommit repository, and then choose Add Users.
Tip
You can use the Search box to quickly find users by name.
8. When you have added your users, close the IAM console.
The following example email provides information for users connecting to the MyDemoRepo repository
with the HTTPS connection protocol and Git credentials in the US East (Ohio) (us-east-2) region. This
email is written with the assumption the user has already installed Git and is familiar with using it.
I've created an AWS CodeCommit repository for us to use while working on our project.
The name of the repository is MyDemoRepo, and
it is in the US East (Ohio) (us-east-2) region.
Here's what you need to do in order to get started using it:
1. Make sure that your version of Git on your local computer is 1.7.9 or later.
2. Generate Git credentials for your IAM user by signing into the IAM console
here: https://console.aws.amazon.com/iam/.
Switch to the Security credentials tab for your IAM user and choose the Generate button
in HTTPS Git credentials for AWS CodeCommit.
Make sure to save your credentials in a secure location!
3. Switch to a directory of your choice and clone the AWS CodeCommit repository to your
local machine by running the following command:
git clone https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo my-demo-
repo
4. When prompted for user name and password, use the Git credentials you just saved.
That's it! If you'd like to learn more about using AWS CodeCommit, you can start with the
tutorial here (p. 60).
Topics
• Using Repository Notifications (p. 85)
• Configure Repository Notifications (p. 86)
• Change, Disable, or Enable Notifications (p. 88)
• Delete Notification Settings for a Repository (p. 89)
• Pull request update events: If you select this option, users receive emails when:
• A pull request is created or closed.
• A pull request is updated with code changes.
• The title or description of the pull request changes.
• Pull request comment events: If you select this option, users receive emails when someone comments
or replies to a comment in a pull request.
• Commit comment events: If you select this option, users receive emails when someone comments on
a commit outside of a pull request. This includes comments on:
• Lines of code in a commit.
• Files in a commit.
Repository notifications are different from repository triggers. Although you can configure a trigger to
use Amazon SNS to send emails about some repository events, those events are limited to operational
events, such as creating branches and pushing code to a branch. Triggers do not use CloudWatch Events
rules to evaluate repository events. They are more limited in scope. For more information about using
triggers, see Manage Triggers for a Repository (p. 90).
To use the AWS CodeCommit console to configure notifications for a repository in AWS CodeCommit,
you must have the following managed policies or the equivalent permissions attached to your IAM user:
• CloudWatchEventsFullAccess
• AmazonSNSFullAccess
Note
Equivalent permissions are included in the AWSCodeCommitFullAccess policy, which is required
to configure repository notifications. If you have this policy applied, you do not need the other
two policies. If you have a customized policy applied, you might need to modify it to include the
required permissions for CloudWatch Events and Amazon SNS.
6. In SNS topic, either choose a topic from the list of Amazon SNS topics in your AWS account, or
create one to use for this repository.
Note
If you create a topic, you can manage subscriptions for that policy from the AWS
CodeCommit console. If you use an existing topic, you cannot manage subscriptions for that
topic unless you have permissions to manage subscriptions for all topics in Amazon SNS.
For more information, see Amazon Simple Notification Service Developer Guide.
If you create a topic, in Topic name, enter a name for the topic after the underscore. (The first part
of the topic name is populated for you. Keep this first part of the name.) Optionally, in Display
name, enter a short name. Choose Create.
7. To add email addresses of the repository users, in Subscribers, choose Add. In Add email subscriber,
enter the email address of a repository user, and then choose Save. You can add only one email
address at a time.
Note
A confirmation email is sent to the address as soon as you choose Save. However, the status
of the subscription is not updated while you remain in Manage subscriptions.
After you have added all the email addresses to the list of subscribers, choose Close.
Tip
Amazon SNS coordinates and manages the delivery and sending of messages to subscribing
endpoints and email addresses. Endpoints include web servers, email addresses, Amazon
Simple Queue Service queues, and AWS Lambda functions. For more information, see What
Is Amazon Simple Notification Service? and Sending Amazon SNS Messages to HTTP/HTTPS
Endpoints in the Amazon SNS Developer Guide.
8. To finish configuring notifications, choose Save.
After you have configured notifications for a repository, you can view the CloudWatch Events rule
automatically created for the repository.
Important
Do not edit or delete this rule. Changing or deleting the rule might cause operational issues.
For example, emails might not be sent to subscribers or you might not be able to change
notification settings for a repository in AWS CodeCommit.
1. Sign in to the AWS Management Console and open the CloudWatch console at https://
console.aws.amazon.com/cloudwatch/.
2. In the navigation bar, under Events, choose Rules.
3. Choose the rule for your repository. The rule name is displayed on the Notifications tab in your
repository settings.
4. View the rule summary information.
Important
Do not edit, delete, or disable this rule.
Disabling notifications is an easy way to temporarily prevent users from receiving emails about
repository events. For example, you might want to disable notifications while you are performing
repository maintenance. Because the configuration is preserved, you can quickly enable notifications
when you are ready.
To permanently delete the notification settings, follow the steps in Delete Notification Settings for a
Repository (p. 89).
To disable notifications
To enable notifications
4. (Optional) To change or delete the Amazon SNS topic used for notifications after you delete
notification settings, go to the Amazon SNS console at https://console.aws.amazon.com/sns/v2/
home. For more information, see Clean Up in Amazon Simple Notification Service Developer Guide.
• Send emails to subscribed users every time someone pushes to the repository.
• Notify an external build system to start a build after someone pushes to the main branch of the
repository.
Scenarios like notifying an external build system require writing a Lambda function to interact with other
applications. The email scenario simply requires creating an Amazon SNS topic.
This topic shows you how to set permissions that allow AWS CodeCommit to trigger actions in Amazon
SNS and Lambda. It also includes links to examples for creating, editing, testing, and deleting triggers.
Topics
• Create the Resource and Add Permissions for AWS CodeCommit (p. 90)
• Example: Create an AWS CodeCommit Trigger for an Amazon SNS Topic (p. 91)
• Example: Create an AWS CodeCommit Trigger for an AWS Lambda Function (p. 95)
• Example: Create a Trigger in AWS CodeCommit for an Existing AWS Lambda Function (p. 98)
• Edit Triggers for an AWS CodeCommit Repository (p. 104)
• Test Triggers for an AWS CodeCommit Repository (p. 105)
• Delete Triggers from an AWS CodeCommit Repository (p. 106)
• For Amazon SNS topics, you do not need to configure additional IAM policies or permissions if the
Amazon SNS topic is created using the same account as the AWS CodeCommit repository. You can
create the AWS CodeCommit trigger as soon as you have created and subscribed to the Amazon SNS
topic.
• For more information about creating topics in Amazon SNS, see the Amazon SNS documentation.
• For information about using Amazon SNS to send messages to Amazon SQS queues, see Sending
Messages to Amazon SQS Queues in the Amazon SNS Developer Guide.
• For information about using Amazon SNS to invoke a Lambda function, see Invoking Lambda
Functions in the Amazon SNS Developer Guide.
• If you want to configure your trigger to use an Amazon SNS topic in another AWS account, you must
first configure that topic with a policy that allows AWS CodeCommit to publish to that topic. For more
information, see Example 1: Create a Policy That Enables Cross-Account Access to an Amazon SNS
Topic (p. 260).
• You can configure Lambda functions by creating the trigger in the Lambda console as part of the
function. This is the simplest method, because triggers created in the Lambda console automatically
include the permissions required for AWS CodeCommit to invoke the Lambda function. If you create
the trigger in AWS CodeCommit, you must include a policy to allow AWS CodeCommit to invoke the
function. For more information, see Create a Trigger for an Existing Lambda Function (p. 98) and
Example 2: Create a Policy for AWS Lambda Integration (p. 261).
Topics
• Create a Trigger to an Amazon SNS Topic for an AWS CodeCommit Repository (Console) (p. 91)
• Create a Trigger to an Amazon SNS Topic for an AWS CodeCommit Repository (AWS CLI) (p. 92)
If this feature does not appear available in the new console experience, choose the navigation bar
option Return to the old experience.
5. In the Create trigger pane, do the following:
• In Trigger name, enter a name for the trigger (for example, MyFirstTrigger).
• In Events, select the repository events that trigger the Amazon SNS topic to send notifications.
If you choose All repository events, you cannot choose any other events. To choose a subset
of events, remove All repository events, and then choose one or more events from the list. For
example, if you want the trigger to run only when a user creates a branch or tag in the AWS
CodeCommit repository, remove All repository events, and then choose Create branch or tag.
• If you want the trigger to apply to all branches of the repository, in Branches, choose All
branches. Otherwise, choose Specific branches. The default branch for the repository is added by
default. You can keep or delete this branch from the list. Choose up to 10 branch names from the
list of repository branches.
• In Send to, choose Amazon SNS.
• In Amazon SNS Topic, choose a topic name from the list, or choose Add an Amazon SNS topic
ARN, and then enter the ARN for the function.
• In Custom data, optionally provide any information you want included in the notification sent
by the Amazon SNS topic (for example, an IRC channel name developers use when discussing
development in this repository). This field is a string. It cannot be used to pass any dynamic
parameters.
6. Optionally, choose Test trigger. This step helps you confirm have correctly configured access
between AWS CodeCommit and the Amazon SNS topic. It uses the Amazon SNS topic to send a
test notification using data from your repository, if available. If no real data is available, the test
notification contains sample data.
7. Choose Create to finish creating the trigger.
For example, to create a trigger for a repository named MyDemoRepo that publishes all repository
events to an Amazon SNS topic named MySNSTopic for two branches, master and preprod:
{
"repositoryName": "MyDemoRepo",
"triggers": [
{
"name": "MyFirstTrigger",
"destinationArn": "arn:aws:sns:us-east-2:80398EXAMPLE:MySNSTopic",
"customData": "",
"branches": [
"master", "preprod"
],
"events": [
"all"
]
}
]
}
There must be a trigger block in the JSON for each trigger for a repository. To create more than
one trigger for the repository, include more than one trigger block in the JSON. Remember that all
triggers created in this file are for the specified repository. You cannot create triggers for multiple
repositories in a single JSON file. For example, if you wanted to create two triggers for a repository,
you could create a JSON file with two trigger blocks. In the following example, no branches are
specified for the second trigger, so that trigger applies to all branches:
{
"repositoryName": "MyDemoRepo",
"triggers": [
{
"name": "MyFirstTrigger",
"destinationArn": "arn:aws:sns:us-east-2:80398EXAMPLE:MySNSTopic",
"customData": "",
"branches": [
"master", "preprod"
],
"events": [
"all"
]
},
{
"name": "MySecondTrigger",
"destinationArn": "arn:aws:sns:us-east-2:80398EXAMPLE:MySNSTopic2",
"customData": "",
"branches": [],
"events": [
"updateReference", "deleteReference"
]
}
]
}
You can create triggers for events you specify, such as when a commit is pushed to a repository.
Event types include:
Note
You can use more than one event type in a trigger. However, if you specify all, you cannot
specify other events.
To see the full list of valid event types, at the terminal or command prompt, type aws codecommit
put-repository-triggers help.
In addition, you can include a string in customData (for example, an IRC channel name developers
use when discussing development in this repository). This field is a string. It cannot be used to pass
any dynamic parameters. This string is appended as an attribute to the AWS CodeCommit JSON
returned in response to the trigger.
2. At a terminal or command prompt, optionally run the test-repository-triggers command. This test
uses sample data from the repository (or generates sample data if no data is available) to send a
notification to the subscribers of the Amazon SNS topic. For example, the following is used to test
that the JSON in the trigger file named trigger.json is valid and that AWS CodeCommit can
publish to the Amazon SNS topic:
{
"successfulExecutions": [
"MyFirstTrigger"
],
"failedExecutions": []
}
3. At a terminal or command prompt, run the put-repository-triggers command to create the trigger
in AWS CodeCommit. For example, to use a JSON file named trigger.json to create the trigger:
{
"configurationId": "0123456-I-AM-AN-EXAMPLE"
}
4. To view the configuration of the trigger, run the get-repository-triggers command, specifying the
name of the repository:
This command returns the structure of all triggers configured for the repository, similar to the
following:
{
"configurationId": "0123456-I-AM-AN-EXAMPLE",
"triggers": [
{
"events": [
"all"
],
"destinationArn": "arn:aws:sns:us-east-2:80398EXAMPLE:MySNSTopic",
"branches": [
"master",
"preprod"
],
"name": "MyFirstTrigger",
"customData": "Project ID 12345"
}
]
}
5. To test the functionality of the trigger itself, make and push a commit to the repository where you
configured the trigger. You should see a response from the Amazon SNS topic. For example, if you
configured the Amazon SNS topic to send an email, you should see an email from Amazon SNS in
the email account subscribed to the topic.
The following is example output from an email sent from Amazon SNS in response to a push to an
AWS CodeCommit repository:
{
"Records":[
{
"awsRegion":"us-east-2",
"codecommit":{
"references" : [
{
"commit":"317f8570EXAMPLE",
"created":true,
"ref":"refs/heads/NewBranch"
},
{
"commit":"4c925148EXAMPLE",
"ref":"refs/heads/preprod",
}
]
},
"eventId":"11111-EXAMPLE-ID",
"eventName":"ReferenceChange",
"eventPartNumber":1,
"eventSource":"aws:codecommit",
"eventSourceARN":"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo",
"eventTime":"2016-02-09T00:08:11.743+0000",
"eventTotalParts":1,
"eventTriggerConfigId":"0123456-I-AM-AN-EXAMPLE",
"eventTriggerName":"MyFirstTrigger",
"eventVersion":"1.0",
"customData":"Project ID 12345",
"userIdentityARN":"arn:aws:iam::80398EXAMPLE:user/JaneDoe-CodeCommit",
}
]
}
Topics
• Create the Lambda Function (p. 95)
• View the Trigger for the Lambda Function in the AWS CodeCommit Repository (p. 98)
1. Sign in to the AWS Management Console and open the AWS Lambda console at https://
console.aws.amazon.com/lambda/.
2. On the Lambda Functions page, choose Create a Lambda function. (If you have not used Lambda
before, choose Get Started Now.)
3. On the Select blueprint page, choose Blank function.
4. On the Configure triggers page, choose AWS CodeCommit from the drop-down list of services to
integrate with Lambda.
• In Repository name, choose the name of the repository where you want to configure a trigger
that uses the Lambda function in response to repository events.
• In Trigger name, enter a name for the trigger (for example, MyLambdaFunctionTrigger).
• In Events, choose the repository events that trigger the Lambda function. If you choose All
repository events, you cannot choose any other events. If you want to choose a subset of events,
clear All repository events, and then choose the events you want from the list. For example, if
you want the trigger to run only when a user creates a tag or a branch in the AWS CodeCommit
repository, remove All repository events, and then choose Create branch or tag.
• If you want the trigger to apply to all branches of the repository, in Branches, choose All
branches. Otherwise, choose Specific branches. The default branch for the repository is added by
default. You can keep or delete this branch from the list. Choose up to 10 branch names from the
list of repository branches.
• In Custom data, optionally enter information you want included in the Lambda function (for
example, the name of the IRC channel used by developers to discuss development in the
repository). This field is a string. It cannot be used to pass any dynamic parameters.
Choose Next.
5. On the Configure function page, in Name, enter a name for the function (for example,
MyCodeCommitFunction). Optionally, in Description, enter a description for the function. If you
want to create a sample JavaScript function, in Runtime, choose Node.js. If you want to create a
sample Python function, choose Python 2.7.
6. In Code entry type, choose Edit code inline, and then replace the hello world code with one of the
two following samples.
For Node.js:
//Get the repository from the event and show its git clone URL
For Python:
import json
import boto3
codecommit = boto3.client('codecommit')
#Get the repository from the event and show its git clone URL
repository = event['Records'][0]['eventSourceARN'].split(':')[5]
try:
response = codecommit.get_repository(repositoryName=repository)
print("Clone URL: " +response['repositoryMetadata']['cloneUrlHttp'])
return response['repositoryMetadata']['cloneUrlHttp']
except Exception as e:
print(e)
print('Error getting repository {}. Make sure it exists and that your
repository is in the same region as this function.'.format(repository))
raise e
• In Handler, leave the default value as derived from the function (index.handler for the Node.js
sample or lambda_function.lambda_handler for the Python sample).
• In Role, choose Create a custom role. In the IAM console, do the following:
• In IAM Role, choose lambda_basic_execution.
• In Policy Name, choose Create a new role policy.
• Choose Allow to create the role and then return to the Lambda console. A value of
lambda_basic_execution should now be displayed for Role.
Note
If you choose a different role or a different name for the role, be sure to use it in the
steps in this topic.
Choose Next.
8. On the Review page, review the settings for the function, and then choose Create function.
If this feature does not appear available in the new console experience, choose the navigation bar
option Return to the old experience.
5. In the Edit trigger pane, choose Test trigger. This option attempts to invoke the function with
sample data about your repository, including the most recent commit ID for the repository. (If no
commit history exists, sample values consisting of zeroes are generated instead.) This helps you
confirm that you have correctly configured access between AWS CodeCommit and the Lambda
function.
6. Choose Cancel after you see a success message from the test.
7. To further verify the functionality of the trigger, make and push a commit to the repository where
you configured the trigger. You should see a response from the Lambda function on the Monitoring
tab for that function in the Lambda console. From the Monitoring tab, choose View logs in
CloudWatch. The CloudWatch console opens in a new tab and displays events for your function.
Select the log stream from the list that corresponds to the time you pushed your commit. You
should see event data similar to the following:
You can also create a trigger for a Lambda function in an AWS CodeCommit repository. Doing so requires
that you choose an existing Lambda function to invoke. It also requires that you manually configure the
permissions required for AWS CodeCommit to run the function.
Topics
• Manually Configure Permissions to Allow AWS CodeCommit to Run a Lambda Function (p. 99)
• Create a Trigger for the Lambda Function in an AWS CodeCommit Repository (Console) (p. 100)
• Create a Trigger to a Lambda Function for an AWS CodeCommit Repository (AWS CLI) (p. 101)
1. Open a plain-text editor and create a JSON file that specifies the Lambda function name, the details
of the AWS CodeCommit repository, and the actions you want to allow in Lambda, similar to the
following:
{
"FunctionName": "MyCodeCommitFunction",
"StatementId": "1",
"Action": "lambda:InvokeFunction",
"Principal": "codecommit.amazonaws.com",
"SourceArn": "arn:aws:codecommit:us-east-1:80398EXAMPLE:MyDemoRepo",
"SourceAccount": "80398EXAMPLE"
}
2. Save the file as a JSON file with a name that is easy for you to remember (for example,
AllowAccessfromMyDemoRepo.json).
3. At the terminal (Linux, macOS, or Unix) or command line (Windows), run the aws lambda add-
permissions command to add a permission to the resource policy associated with your Lambda
function, using the JSON file you just created:
This command returns the JSON of the policy statement you just added, similar to the following:
{
"Statement": "{\"Condition\":{\"StringEquals\":{\"AWS:SourceAccount\":
\"80398EXAMPLE\"},\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:codecommit:us-
east-1:80398EXAMPLE:MyDemoRepo\"}},\"Action\":[\"lambda:InvokeFunction\"],\"Resource
\":\"arn:aws:lambda:us-east-1:80398EXAMPLE:function:MyCodeCommitFunction\",\"Effect\":
\"Allow\",\"Principal\":{\"Service\":\"codecommit.amazonaws.com\"},\"Sid\":\"1\"}"
}
For more information about resource policies for Lambda functions, see AddPermission and The
Pull/Push Event Models in the Lambda User Guide.
4. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
5. In the Dashboard navigation pane, choose Roles, and in the list of roles, select
lambda_basic_execution.
6. On the summary page for the role, choose the Permissions tab, and in Inline Policies, choose
Create Role Policy.
7. On the Set Permissions page, choose Policy Generator, and then choose Select.
8. On the Edit Permissions page, do the following:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt11111111",
"Effect": "Allow",
"Action": [
"codecommit:GetRepository"
],
"Resource": [
"arn:aws:codecommit:us-east-1:80398EXAMPLE:MyDemoRepo"
]
}
]
}
If this feature does not appear available in the new console experience, choose the navigation bar
option Return to the old experience.
5. In Create trigger, do the following:
• In Trigger name, enter a name for the trigger (for example, MyLambdaFunctionTrigger).
• In Events, choose the repository events that trigger the Lambda function.
If you choose All repository events, you cannot choose any other events. If you want to choose a
subset of events, clear All repository events, and then choose the events you want from the list.
For example, if you want the trigger to run only when a user creates a tag or a branch in the AWS
CodeCommit repository, remove All repository events, and then choose Create branch or tag.
• If you want the trigger to apply to all branches of the repository, in Branches, choose All
branches. Otherwise, choose Specific branches. The default branch for the repository is added by
default. You can keep or delete this branch from the list. Choose up to 10 branch names from the
list of repository branches.
• In Send to, choose AWS Lambda.
• In Lambda function ARN, choose the function name from the list, or choose Add an AWS Lambda
function ARN and then enter the ARN for the function.
• In Custom data, optionally enter information you want included in the Lambda function (for
example, the name of the IRC channel used by developers to discuss development in the
repository). This field is a string. It cannot be used to pass any dynamic parameters.
6. Optionally, choose Test trigger. This option attempts to invoke the function with sample data about
your repository, including the most recent commit ID for the repository. (If no commit history exists,
sample values consisting of zeroes are generated instead.) This helps you confirm that you have
correctly configured access between AWS CodeCommit and the Lambda function.
7. Choose Create to finish creating the trigger.
8. To verify the functionality of the trigger, make and push a commit to the repository where you
configured the trigger. You should see a response from the Lambda function on the Monitoring tab
for that function in the Lambda console.
For example, if you want to create a trigger for a repository named MyDemoRepo that publishes all
repository events to a Lambda function named MyCodeCommitFunction for two branches, master
and preprod:
{
"repositoryName": "MyDemoRepo",
"triggers": [
{
"name": "MyLambdaFunctionTrigger",
"destinationArn": "arn:aws:lambda:us-
east-1:80398EXAMPLE:function:MyCodeCommitFunction",
"customData": "",
"branches": [
"master", "preprod"
],
"events": [
"all"
]
}
]
}
There must be a trigger block in the JSON for each trigger for a repository. To create more than one
trigger for a repository, include additional blocks in the JSON. Remember that all triggers created
in this file are for the specified repository. You cannot create triggers for multiple repositories in
a single JSON file. For example, if you wanted to create two triggers for a repository, you could
create a JSON file with two trigger blocks. In the following example, no branches are specified in the
second trigger block, so that trigger applies to all branches:
{
"repositoryName": "MyDemoRepo",
"triggers": [
{
"name": "MyLambdaFunctionTrigger",
"destinationArn": "arn:aws:lambda:us-
east-1:80398EXAMPLE:function:MyCodeCommitFunction",
"customData": "",
"branches": [
"master", "preprod"
],
"events": [
"all"
]
},
{
"name": "MyOtherLambdaFunctionTrigger",
"destinationArn": "arn:aws:lambda:us-
east-1:80398EXAMPLE:function:MyOtherCodeCommitFunction",
"customData": "",
"branches": [],
"events": [
"updateReference", "deleteReference"
]
}
]
}
You can create triggers for events you specify, such as when a commit is pushed to a repository.
Event types include:
Note
You can use more than one event type in a trigger. However, if you specify all, you cannot
specify other events.
To see the full list of valid event types, at the terminal or command prompt, enter aws codecommit
put-repository-triggers help.
In addition, you can include a string in customData (for example, an IRC channel name developers
use when discussing development in this repository). This field is a string. It cannot be used to pass
any dynamic parameters. This string is appended as an attribute to the AWS CodeCommit JSON
returned in response to the trigger.
2. At a terminal or command prompt, optionally run the test-repository-triggers command. For
example, the following is used to test that the JSON file named trigger.json is valid and that
AWS CodeCommit can trigger the Lambda function. This test uses sample data to trigger the
function if no real data is available.
{
"successfulExecutions": [
"MyLambdaFunctionTrigger"
],
"failedExecutions": []
}
3. At a terminal or command prompt, run the put-repository-triggers command to create the trigger
in AWS CodeCommit. For example, to use a JSON file named trigger.json to create the trigger:
{
"configurationId": "0123456-I-AM-AN-EXAMPLE"
}
4. To view the configuration of the trigger, run the get-repository-triggers command, specifying the
name of the repository:
This command returns the structure of all triggers configured for the repository, similar to the
following:
{
"configurationId": "0123456-I-AM-AN-EXAMPLE",
"triggers": [
{
"events": [
"all"
],
"destinationArn": "arn:aws:lambda:us-
east-1:80398EXAMPLE:MyCodeCommitFunction",
"branches": [
"master",
"preprod"
],
"name": "MyLambdaFunctionTrigger",
"customData": "Project ID 12345"
}
]
}
5. To test the functionality of the trigger, make and push a commit to the repository where you
configured the trigger. You should see a response from the Lambda function on the Monitoring tab
for that function in the Lambda console.
API Version 2015-04-13
103
AWS CodeCommit User Guide
Edit Triggers for a Repository
Topics
• Edit a Trigger for a Repository (Console) (p. 104)
• Edit a Trigger for a Repository (AWS CLI) (p. 104)
If this feature does not appear available in the new console experience, choose the navigation bar
option Return to the old experience.
5. Make the changes you want to the trigger, and then choose Update to save your changes.
This command returns nothing, but a file named MyTriggers.json is created in the directory
where you ran the command.
2. Edit the JSON file in a plain-text editor and make changes to the trigger block of the trigger you
want to edit. Replace the configurationId pair with a repositoryName pair. Save the file.
For example, if you want to edit a trigger named MyFirstTrigger in the repository named
MyDemoRepo so that it applies to all branches, you would replace configurationId with
repositoryName, and remove the specified master and preprod branches in red italic text.
By default, if no branches are specified, the trigger applies to all branches in the repository:
{
"repositoryName": "MyDemoRepo",
"triggers": [
{
"destinationArn": "arn:aws:sns:us-east-2:80398EXAMPLE:MyCodeCommitTopic",
"branches": [
"master",
"preprod"
],
"name": "MyFirstTrigger",
"customData": "",
"events": [
"all"
]
}
]
}
3. At the terminal or command line, run the put-repository-triggers command. This updates all
triggers for the repository, including the changes you made to the MyFirstTrigger trigger:
{
"configurationId": "0123456-I-AM-AN-EXAMPLE"
}
Topics
• Test a Trigger for a Repository (Console) (p. 105)
• Test a Trigger for a Repository (AWS CLI) (p. 105)
If this feature does not appear available in the new console experience, choose the navigation bar
option Return to the old experience.
5. In Edit trigger, choose Test trigger. You should see a success or failure message. If successful, you
should also see a corresponding action response from the Lambda function or the Amazon SNS
topic.
This command creates a file named TestTriggers.json in the directory where you ran the
command.
2. Edit the JSON file in a plain-text editor and make the changes to the trigger statement. Replace the
configurationId pair with a repositoryName pair. Save the file.
For example, if you want to test a trigger named MyFirstTrigger in the repository
named MyDemoRepo so that it applies to all branches, replace the configurationId with
repositoryName and then save a file that looks similar to the following as TestTrigger.json:
{
"repositoryName": "MyDemoRepo",
"triggers": [
{
"destinationArn": "arn:aws:sns:us-east-2:80398EXAMPLE:MyCodeCommitTopic",
"branches": [
"master",
"preprod"
],
"name": "MyFirstTrigger",
"customData": "",
"events": [
"all"
]
}
]
}
3. At the terminal or command line, run the test-repository-triggers command. This updates all
triggers for the repository, including the changes you made to the MyFirstTrigger trigger:
{
"successfulExecutions": [
"MyFirstTrigger"
],
"failedExecutions": []
}
Topics
• Delete a Trigger from a Repository (Console) (p. 107)
• Delete a Trigger from a Repository (AWS CLI) (p. 107)
If this feature does not appear available in the new console experience, choose the navigation bar
option Return to the old experience.
5. In the dialog box, choose Delete to confirm.
This command creates a file named MyTriggers.json in the directory where you ran the
command.
2. Edit the JSON file in a plain-text editor and remove the trigger block for the trigger you want to
delete. Replace the configurationId pair with a repositoryName pair. Save the file.
For example, if you want to remove a trigger named MyFirstTrigger from the repository named
MyDemoRepo, you would replace configurationId with repositoryName, and remove the
statement in red italic text:
{
"repositoryName": "MyDemoRepo",
"triggers": [
{
"destinationArn": "arn:aws:sns:us-east-2:80398EXAMPLE:MyCodeCommitTopic",
"branches": [
"master",
"preprod"
],
"name": "MyFirstTrigger",
"customData": "",
"events": [
"all"
]
},
{
"destinationArn": "arn:aws:lambda:us-
east-2:80398EXAMPLE:function:MyCodeCommitJSFunction",
"branches": [],
"name": "MyLambdaTrigger",
"events": [
"all"
]
}
]
}
3. At the terminal or command line, run the put-repository-triggers command. This updates the
triggers for the repository and deletes the MyFirstTrigger trigger:
{
"configurationId": "0123456-I-AM-AN-EXAMPLE"
}
Note
To delete all triggers for a repository named MyDemoRepo, your JSON file would look
similar to this:
{
"repositoryName": "MyDemoRepo",
"triggers": []
}
Before you follow these instructions, complete the steps in Setting Up (p. 4).
Topics
• View Repository Details (Console) (p. 108)
• View AWS CodeCommit Repository Details (Git) (p. 109)
• View AWS CodeCommit Repository Details (AWS CLI) (p. 110)
• To view the URL for cloning the repository, choose Clone URL, and then choose the protocol you
want to use when cloning the repository. This copies the clone URL. To review it, paste it into a
plain-text editor.
• To view configurable details for the repository, in the navigation pane, choose Settings.
Note
If you are signed in as an IAM user, you can configure and save your preferences for viewing code
and other console settings. For more information, see Working with User Preferences (p. 204).
Before you perform these steps, connect the local repo to the AWS CodeCommit repository. For
instructions, see Connect to a Repository (p. 78).
1. Run the git remote show remote-name command, where remote-name is the alias of the AWS
CodeCommit repository (by default, origin).
Tip
To get a list of AWS CodeCommit repository names and their URLs, run the git remote -v
command.
For example, to view details about the AWS CodeCommit repository with the alias origin:
2. For HTTPS:
* remote origin
Fetch URL: https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo
Push URL: https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo
HEAD branch: (unknown)
Remote branches:
MyNewBranch tracked
master tracked
Local ref configured for 'git pull':
MyNewBranch merges with remote MyNewBranch (up to date)
Local refs configured for 'git push':
MyNewBranch pushes to MyNewBranch (up to date)
master pushes to master (up to date)
For SSH:
* remote origin
Fetch URL: ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo
Push URL: ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo
HEAD branch: (unknown)
Remote branches:
MyNewBranch tracked
master tracked
Local ref configured for 'git pull':
MyNewBranch merges with remote MyNewBranch (up to date)
Local refs configured for 'git push':
MyNewBranch pushes to MyNewBranch (up to date)
master pushes to master (up to date)
Tip
To look up the SSH key ID for your IAM user, open the IAM console and expand Security
Credentials on the IAM user details page. The SSH key ID can be found in SSH Keys for
AWS CodeCommit.
To use the AWS CLI to view repository details, run the following commands:
• list-repositories (p. 110) to view a list of AWS CodeCommit repository names and their corresponding
IDs.
• get-repository (p. 110) to view information about a single AWS CodeCommit repository.
• batch-get-repositories (p. 111) to view information about multiple repositories in AWS CodeCommit.
You can use the optional --sort-by or --order options to change the order of returned
information.
2. If successful, this command outputs a repositories object that contains the names and IDs of all
repositories in AWS CodeCommit associated with the AWS account.
{
"repositories": [
{
"repositoryName": "MyDemoRepo"
"repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE",
},
{
"repositoryName": "MyOtherDemoRepo"
"repositoryId": "cfc29ac4-b0cb-44dc-9990-f6f51EXAMPLE"
}
]
}
For example, to view details about an AWS CodeCommit repository named MyDemoRepo:
2. If successful, this command outputs a repositoryMetadata object with the following information:
{
"repositoryMetadata": {
"creationDate": 1429203623.625,
"defaultBranch": "master",
"repositoryName": "MyDemoRepo",
"cloneUrlSsh": "ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/
MyDemoRepo",
"lastModifiedDate": 1430783812.0869999,
"repositoryDescription": "My demonstration repository",
"cloneUrlHttp": "https://codecommit.us-east-2.amazonaws.com/v1/repos/
MyDemoRepo",
"repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE",
"Arn": "arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo
"accountId": "111111111111"
}
}
For example, to view details about two AWS CodeCommit repositories named MyDemoRepo and
MyOtherDemoRepo:
• A list of any AWS CodeCommit repositories that could not be found (repositoriesNotFound).
• A list of AWS CodeCommit repositories (repositories). Each AWS CodeCommit repository name
is followed by:
• The repository's description (repositoryDescription).
• The repository's unique, system-generated ID (repositoryId).
• The ID of the AWS account associated with the repository (accountId).
{
"repositoriesNotFound": [],
"repositories": [
{
"creationDate": 1429203623.625,
"defaultBranch": "master",
"repositoryName": "MyDemoRepo",
"cloneUrlSsh": "ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/
MyDemoRepo",
API Version 2015-04-13
111
AWS CodeCommit User Guide
Change Repository Settings
"lastModifiedDate": 1430783812.0869999,
"repositoryDescription": "My demonstration repository",
"cloneUrlHttp": "https://codecommit.us-east-2.amazonaws.com/v1/repos/
MyDemoRepo",
"repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE",
"Arn": "arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo
"accountId": "111111111111"
},
{
"creationDate": 1429203623.627,
"defaultBranch": "master",
"repositoryName": "MyOtherDemoRepo",
"cloneUrlSsh": "ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/
MyOtherDemoRepo",
"lastModifiedDate": 1430783812.0889999,
"repositoryDescription": "My other demonstration repository",
"cloneUrlHttp": "https://codecommit.us-east-2.amazonaws.com/v1/repos/
MyOtherDemoRepo",
"repositoryId": "cfc29ac4-b0cb-44dc-9990-f6f51EXAMPLE",
"Arn": "arn:aws:codecommit:us-east-2:80398EXAMPLE:MyOtherDemoRepo
"accountId": "111111111111"
}
],
"repositoriesNotFound": []
}
Topics
• Change Repository Settings (Console) (p. 112)
• Change AWS CodeCommit Repository Settings (AWS CLI) (p. 113)
will change, changing the repository name will invalidate any IAM user policies that rely on
this repository's ARN.
To connect to the repository after the name is changed, each user must use the git remote
set-url command and specify the new URL to use. For example, if you changed the name
of the repository from MyDemoRepo to MyRenamedDemoRepo, users who use HTTPS to
connect to the repository would run the following Git command:
Users who use SSH to connect to the repository would run the following Git command:
To use AWS CLI to change an AWS CodeCommit repository's settings in AWS CodeCommit, run one or
more of the following commands:
• The name of the AWS CodeCommit repository (with the --repository-name option).
Tip
To get the name of the AWS CodeCommit repository, run the list-repositories (p. 110)
command.
• The new repository description (with the --repository-description option).
Note
The description field displays Markdown in the console and accepts all HTML characters
and valid Unicode characters. If you are an application developer who is using the
GetRepository or BatchGetRepositories APIs and you plan to display the
repository description field in a web browser, see the AWS CodeCommit API Reference.
For example, to change the description for the AWS CodeCommit repository named MyDemoRepo to
This description was changed:
• The current name of the AWS CodeCommit repository (with the --old-name option).
Tip
To get the AWS CodeCommit repository's name, run the list-repositories (p. 110)
command.
• The new name of the AWS CodeCommit repository (with the --new-name option).
To push changes from the local repo to the AWS CodeCommit repository, run git push remote-name
branch-name.
To pull changes to the local repo from the AWS CodeCommit repository, run git pull remote-name
branch-name.
For both pushing and pulling, remote-name is the nickname the local repo uses for the AWS
CodeCommit repository. branch-name is the name of the branch on the AWS CodeCommit repository to
push to or pull from.
Tip
To get the nickname the local repo uses for the AWS CodeCommit repository, run git remote.
To get a list of branch names, run git branch. An asterisk (*) appears next to the name of the
current branch. (Alternatively, run git status to show the current branch name.)
Note
If you cloned the repository, from the perspective of the local repo, remote-name is not the
name of the AWS CodeCommit repository. When you clone a repository, remote-name is set
automatically to origin.
For example, to push changes from the local repo to the master branch in the AWS CodeCommit
repository with the nickname origin:
Similarly, to pull changes to the local repo from the master branch in the AWS CodeCommit repository
with the nickname origin:
Tip
If you add the -u option to git push, you set upstream tracking information. For example, if you
run git push -u origin master), in the future you can run git push and git pull without remote-
name branch-name. To get upstream tracking information, run git remote show remote-name
(for example, git remote show origin).
1. From the command prompt or terminal, switch to your local repo directory and run the git remote -
v command. You should see output similar to the following:
For HTTPS:
For SSH:
2. Run the git remote set-url --add --push origin git-repository-name command where git-
repository-name is the URL and name of the Git repository where you want to host your code.
This changes the push destination of origin to that Git repository.
Note
git remote set-url --add --push overrides the default URL for pushes, so you must run this
command twice, as demonstrated in later steps.
For example, the following command changes the push of origin to some-URL/MyDestinationRepo:
For HTTPS:
For SSH:
4. Now add the AWS CodeCommit repository. Run git remote set-url --add --push origin again, this
time with the URL and repository name of your AWS CodeCommit repository.
For example, the following command adds the push of origin to https://git-codecommit.us-
east-2.amazonaws.com/v1/repos/MyDemoRepo:
For HTTPS:
For SSH:
API Version 2015-04-13
116
AWS CodeCommit User Guide
Push Commits to Two Repositories
For HTTPS:
For SSH:
You now have two Git repositories as the destination for your pushes, but your pushes go to some-
URL/MyDestinationRepo first. If the push to that repository fails, your commits are not pushed to
either repository.
Tip
If the other repository requires credentials you want to enter manually, consider changing
the order of the pushes so that you push to AWS CodeCommit first. Run git remote set-url
--delete to delete the repository that is pushed to first, and then run git remote set-url --
add to add it again so that it becomes the second push destination in the list.
For more options, see your Git documentation.
6. To verify you are now pushing to both remote repositories, use a text editor to create the following
text file in your local repo:
bees.txt
-------
Bees are flying insects closely related to wasps and ants, and are known for their role
in pollination and for producing honey and beeswax.
9. To push the commit from the local repo to your remote repositories, run git push -u remote-name
branch-name where remote-name is the nickname the local repo uses for the remote repositories
and branch-name is the name of the branch to push to the repository.
Tip
You only have to use the -u option the first time you push. Then the upstream tracking
information is set.
For example, running git push -u origin master would show the push went to both remote
repositories in the expected branches, with output similar to the following:
For HTTPS:
API Version 2015-04-13
117
AWS CodeCommit User Guide
Configure Cross-Account Access to a Repository
For SSH:
• The administrator in AccountA signs in as an IAM user with the permissions required to create and
manage repositories in AWS CodeCommit and create roles in IAM. If you are using managed policies,
apply IAMFullAccess and AWSCodeCommitFullAccess to this IAM user.
Topics
• Cross-Account Repository Access: Actions for the Administrator in AccountA (p. 119)
• Cross Account Repository Access: Actions for the Administrator in AccountB (p. 122)
• Cross-Account Repository Access: Actions for the Repository User in AccountB (p. 123)
Topics
• Step 1: Create a Policy for Repository Access in AccountA (p. 119)
• Step 2: Create a Role for Repository Access in AccountA (p. 121)
• Configure the policy to allow AccountB users access to a specific repository, but do not allow them to
view a list of all repositories in AccountA.
API Version 2015-04-13
119
AWS CodeCommit User Guide
Cross-Account Repository Access: Actions
for the Administrator in AccountA
• Configure additional access to allow AccountB users to choose the repository from a list of all
repositories in AccountA.
1. Sign in to the AWS Management Console as an IAM user with permissions to create roles in
AccountA.
2. Open the IAM console at https://console.aws.amazon.com/iam/.
3. In the navigation pane, choose Policies.
4. Choose Create policy.
5. Choose the JSON tab, and paste the following JSON policy document into the JSON text box.
Replace us-east-2 with the region for the repository, 111122223333 with the account ID for
AccountA, and MySharedDemoRepo with the name for your AWS CodeCommit repository in
AccountA:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:BatchGet*",
"codecommit:Create*",
"codecommit:DeleteBranch",
"codecommit:Get*",
"codecommit:List*",
"codecommit:Describe*",
"codecommit:Put*",
"codecommit:Post*",
"codecommit:Merge*",
"codecommit:Test*",
"codecommit:Update*",
"codecommit:GitPull",
"codecommit:GitPush"
],
"Resource": [
"arn:aws:codecommit:us-east-2:111122223333:MySharedDemoRepo"
]
}
]
}
If you want users who assume this role to be able to view a list of repositories on the AWS
CodeCommit console home page, add an additional statement to the policy, as follows:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:BatchGet*",
"codecommit:Create*",
"codecommit:DeleteBranch",
"codecommit:Get*",
"codecommit:List*",
"codecommit:Describe*",
"codecommit:Put*",
"codecommit:Post*",
"codecommit:Merge*",
"codecommit:Test*",
"codecommit:Update*",
"codecommit:GitPull",
"codecommit:GitPush"
],
"Resource": [
"arn:aws:codecommit:us-east-2:111122223333:MySharedDemoRepo"
]
},
{
"Effect": "Allow",
"Action": "codecommit:ListRepositories",
"Resource": "*"
}
]
}
This access makes it easier for users who assume this role to find the repository to which they have
access. They can choose the name of the repository from the list and be directed to the home page
of the shared repository (Code). Users cannot access any of the other repositories they see in the list,
but they can view the repositories in AccountA on the Dashboard page.
If you do not want to allow users who assume the role to be able to view a list of all repositories in
AccountA, use the first policy example, but make sure that you send those users a direct link to the
home page of the shared repository in the AWS CodeCommit console.
6. Choose Review policy. The policy validator reports syntax errors (for example, if you forget to
replace the example AWS account ID and repository name with your AWS account ID and repository
name).
7. On the Review policy page, type a name for the policy (for example,
CrossAccountAccessForMySharedDemoRepo). You can also provide an optional description for
this policy. Choose Create policy.
Topics
• Step 1: Create an IAM Group for Repository Access for AccountB Users (p. 122)
• Step 2: Create a Policy and Add Users to the IAM Group (p. 122)
1. Sign in to the AWS Management Console as an IAM user with the permissions required to create IAM
groups and policies and manage IAM users in AccountB.
2. Open the IAM console at https://console.aws.amazon.com/iam/.
3. In the IAM console, choose Groups.
4. Choose Create New Group.
5. In Group Name, type a name for the group (for example,
DevelopersWithCrossAccountRepositoryAccess). Choose Next Step.
6. In Attach Policy, choose Next Step. You create the cross-account policy in the next procedure. Finish
creating the group.
1. In the IAM console, choose Groups, and then choose the name of the group you just created (for
example, DevelopersWithCrossAccountRepositoryAccess).
2. Choose the Permissions tab. Expand Inline Policies, and then choose the link to create an inline
policy. (If you are configuring a group that already has an inline policy, choose Create Group Policy.)
3. Choose Custom Policy, and then choose Select.
4. In Policy Name, type a name for the policy (for example, AccessPolicyForSharedRepository).
5. In Policy Document, paste the following policy. In Resource, replace the ARN
with the ARN of the policy created by the administrator in AccountA (for example,
arn:aws:iam::111122223333:role/MyCrossAccountRepositoryContributorRole), and then
choose Apply Policy. For more information about the policy created by the administrator in
AccountA, see Step 1: Create a Policy for Repository Access in AccountA (p. 119).
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource":
"arn:aws:iam::111122223333:role/MyCrossAccountRepositoryContributorRole"
}
}
6. Choose the Users tab. Choose Add Users to Group, and then add the AccountB IAM users. For
example, you might add an IAM user with the user name Saanvi_Sarkar to the group.
Note
Users in AccountB must have programmatic access, including an access key and secret key,
to configure their local computers for access to the shared AWS CodeCommit repository.
If you are creating IAM users, be sure to save the access key and secret key. To ensure the
security of your AWS account, the secret access key is accessible only at the time you create
it.
Topics
• Step 1: Configure the AWS CLI and Git for an AccountB User to Access the Repository in
AccountA (p. 123)
• Step 2: Clone and Access the AWS CodeCommit Repository in AccountA (p. 125)
Step 1: Configure the AWS CLI and Git for an AccountB User to
Access the Repository in AccountA
You must use the credential helper, not SSH keys or Git credentials, to access repositories in another
AWS account. AccountB users must configure their computers to use the credential helper to access the
shared AWS CodeCommit repository in AccountA. You cannot use SSH keys or Git credentials to access
repositories in another AWS account. However, you can continue to use SSH keys or Git credentials when
accessing repositories in AccountB.
1. Install the AWS CLI on the local computer. For more information, see instructions for your operating
system in Installing the AWS CLI.
2. Install Git on the local computer. To install Git, we recommend websites such as Git Downloads or
Git for Windows.
When you install Git, do not install the Git Credential Manager. The Git Credential Manager is not
compatible with the credential helper included with the AWS CLI.
Note
AWS CodeCommit supports Git versions 1.7.9 and later. Git is an evolving, regularly
updated platform. Occasionally, a feature change might affect the way it works with AWS
CodeCommit. If you encounter issues with a specific version of Git and AWS CodeCommit,
review the information in Troubleshooting (p. 228).
3. From the terminal or command line, at the directory location where you want to clone the
repository, run the git config --local user.name and git config --local user.email commands to set
the user name and email for the commits you will make to the repository. For example:
These commands return nothing, but the email and user name you specify will be associated with
the commits you make to the repository in AccountA.
4. Run the aws configure --profile command to configure a default profile to use when connecting to
resources in AccountB. When prompted, provide the access key and secret key for your IAM user.
Note
If you have already installed the AWS CLI and configured a profile, you can skip this step.
For example, run the following command to create a default AWS CLI profile that you use to access
AWS resources in AccountA in US East (Ohio) (us-east-2):
aws configure
5. Run the aws configure --profile command again to configure a named profile to use when
connecting to the repository in AccountA. When prompted, provide the access key and secret key
for your IAM user. For example, run the following command to create an AWS CLI profile named
MyCrossAccountAccessProfile that you use to access a repository in AccountA in US East (Ohio)
(us-east-2):
6. In a plain-text editor, open the config file, also known as the AWS CLI configuration file. Depending
on your operating system, this file might be located at ~/.aws/config on Linux, macOS, or Unix,
or at drive:\Users\USERNAME\.aws\config on Windows.
7. In the file, find the entry that corresponds to the MyCrossAccountAccessProfile profile you just
created. It should look similar to the following:
[profile MyCrossAccountAccessProfile]
region = US East (Ohio)
output = json
Add two lines to the profile configuration, role_arn and source_profile. Provide the ARN of the
role in AccountA you will assume to access the repository in the other account, and the name of your
default AWS CLI profile in AccountB. For example:
[profile MyCrossAccountAccessProfile]
region = US East (Ohio)
role_arn = arn:aws:iam::111122223333:role/MyCrossAccountRepositoryContributorRole
source_profile = default
output = json
9. Run the git config -l command to verify your configuration. A successful configuration contains lines
similar to the following:
user.name=Saanvi Sarkar
[email protected]
credential.helper=!aws --profile MyCrossAccountAccessProfile codecommit credential-
helper $@
credential.usehttppath=true
Note
If you see the following line in your configuration file, another credential manager is
configured for your system, which can prevent the AWS CLI credential helper from working:
credential.helper=manager
https://console.aws.amazon.com/codecommit/home?region=us-east-2#/
repository/MySharedDemoRepo/browse/HEAD/--/
1. At the command line or terminal, in the directory where you want to clone the repository, run the
git clone command with the HTTPS clone URL. For example:
Unless you specify otherwise, the repository is cloned into a subdirectory with the same name as the
repository.
2. Change directories to the cloned repository, and either make a change to a file or add a file. For
example, you could add a file named NewFile.txt.
3. Add the file to the tracked changes for the local repo, commit the change, and push the file to the
AWS CodeCommit repository. For example:
For more information, see Git with AWS CodeCommit Tutorial (p. 58).
Now that you've added a file, go to the AWS CodeCommit console to view your commit, review other
users' changes to the repo, participate in pull requests, and more.
1. Sign in to the AWS Management Console in AccountB (888888888888) as the IAM user who has
been granted cross-account access to the repository in AccountA.
2. Choose your user name on the navigation bar, and in the drop-down list, choose Switch Role.
Note
If this is the first time you have selected this option, review the information on the page,
and then choose Switch Role again.
3. On the Switch Role page, do the following:
If the assumed role has permission to view the names of repositories in AccountA, you see a list of
repositories and an error message that informs you that you do not have permissions to view their
status. This is expected behavior. Choose the name of the shared repository from the list.
If the assumed role does not have permission to view the names of repositories in AccountA, you
see an error message and a blank list with no repositories. Paste the URL link to the repository
or modify the console link and change /list to the name of the shared repository (for example,
/MySharedDemoRepo).
5. In Code, find the name of the file you added from your local computer. Choose it to browse the code
in the file, and then browse the rest of the repository and start using its features.
For more information, see Getting Started with AWS CodeCommit Tutorial (p. 43).
Topics
• Delete a Repository (Console) (p. 127)
• Delete a Local Repo (p. 127)
• Delete an AWS CodeCommit Repository (AWS CLI) (p. 127)
Deleting a local repo does not delete any AWS CodeCommit repository to which it might be connected.
To use the AWS CLI to delete an AWS CodeCommit repository, run the delete-repository command,
specifying the name of the AWS CodeCommit repository to delete (with the --repository-name
option).
Important
After you delete an AWS CodeCommit repository, you are no longer able to clone it to any local
repo or shared repo. You are also no longer able to pull data from it, or push data to it, from any
local repo or shared repo. This action cannot be undone.
Tip
To get the name of the AWS CodeCommit repository, run the list-repositories (p. 110)
command.
If successful, the ID of the AWS CodeCommit repository that was permanently deleted appears in the
output:
{
"repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE"
}
Deleting an AWS CodeCommit repository does not delete any local repos that might be connected to it.
To add a file to a repository, or edit an existing file in a repository, you can use a Git client. You can also
use the AWS CodeCommit console, the AWS CLI, or the AWS CodeCommit API.
For information about working with other aspects of your repository in AWS CodeCommit, see Working
with Repositories (p. 75), Working with Pull Requests (p. 138), Working with Branches (p. 190),
Working with Commits (p. 160), and Working with User Preferences (p. 204).
Topics
• Browse Files in an AWS CodeCommit Repository (p. 130)
• Create or Add a File to an AWS CodeCommit Repository (p. 131)
• Edit the Contents of a File in an AWS CodeCommit Repository (p. 134)
2. On the Repositories page, from the list of repositories, choose the repository you want to browse.
3. In the Code view, browse the contents of the default branch for your repository.
To change the view to a different branch or tag, choose the view selector button. Either choose a
branch or tag name from the drop-down list, or in the filter box, enter the name of the branch or
tag, and then choose it from the list.
4. Do one of the following:
• To view the contents of a directory, choose it from the list. You can choose any of the directories in
the navigation list to return to that directory view. You can also use the up arrow at the top of the
directory list.
• To view the contents of a file, choose it from the list. If the file is larger than the commit object
limit, it cannot be displayed in the console and must be viewed in a local repo instead. For more
information, see Limits (p. 277). To exit the file view, from the code navigation bar, choose the
directory you want to view.
Note
If you choose a binary file, a warning message appears, asking you to confirm that you want
to display the contents. To view the file, choose Show file contents. If you do not want to
view the file, from the code navigation bar, choose the directory you want to view.
If you choose a markdown file (.md), use the Rendered Markdown and Markdown Source
buttons to toggle between the rendered and syntax views.
Topics
• Create or Upload a File (Console) (p. 132)
• Add a File (AWS CLI) (p. 133)
• Add a File (Git) (p. 134)
To change the view to a different branch, choose the view selector button. Either choose a branch
name from the drop-down list, or in the filter box, enter the name of the branch, and then choose it
from the list.
4. Choose Add file, and then choose one of the following options:
• Create file, to use the code editor to create the contents of a file and add it to the repository.
• Upload file, to upload a file from your local computer to the repository.
5. Provide information to other users about who added this file to the repository and why.
• In Author name, enter your name. This name is used as both the author name and the committer
name in the commit information. AWS CodeCommit defaults to using your IAM user name or a
derivation of your console login as the author name.
• In Email address, enter an email address so that other repository users can contact you about this
change.
• In Commit message, enter a brief description. This is optional, but highly recommended.
Otherwise, a default commit message is used.
6. Do one of the following:
• If you are uploading a file, choose the file from your local computer.
• If you are creating a file, enter the content you want to add in the code editor, and provide a name
for the file.
7. Choose Commit changes.
1. On your local computer, create the file you want to add to the AWS CodeCommit repository.
2. At the terminal or command line, run the put-file command, specifying:
The user name, email address, and commit message are optional, but help other users know who
made the change and why. If you do not supply a user name, AWS CodeCommit defaults to using
your IAM user name or a derivation of your console login as the author name.
Note
When you add binary files, make sure that you use fileb:// to specify the local location
of the file.
{
"blobId": "2eb4af3bEXAMPLE",
"commitId": "317f8570EXAMPLE",
"treeId": "347a3408EXAMPLE"
}
Topics
• Edit a File (Console) (p. 135)
• Edit a File (AWS CLI) (p. 136)
• Edit a File (Git) (p. 137)
To change the view to a different branch, choose the view selector button. Either choose a branch
name from the drop-down list, or in the filter box, enter the name of the branch, and then choose it
from the list.
4. Navigate the contents of the branch and choose the file you want to edit. In the file view, choose
Edit.
Note
If you choose a binary file, a warning message appears asking you to confirm that you want
to display the contents. You should not use the AWS CodeCommit console to edit binary
files.
5. Edit the file, and provide information to other users about who made this change and why.
• In Author name, enter your name. This name is used as both the author name and the committer
name in the commit information. AWS CodeCommit defaults to using your IAM user name or a
derivation of your console login as the author name.
• In Email address, enter an email address so that other repository users can contact you about this
change.
• In Commit message, enter a brief description of your changes.
6. Choose Commit changes to save your changes to the file and commit the changes to the repository.
1. Using a local copy of the file, make the changes you want to add to the AWS CodeCommit
repository.
2. At the terminal or command line, run the put-file command, specifying:
The user name, email address, and commit message are optional, but help other users know who
made the change and why. If you do not supply a user name, AWS CodeCommit defaults to using
your IAM user name or a derivation of your console login.
For example, to add edits made to a file named ExampleSolution.py to a repository named
MyDemoRepo to a branch named feature-randomizationfeature whose most recent commit
has an ID of 4c925148EXAMPLE:
Note
If you want to add a changed binary file, make sure to use --file-content with the
notation fileb://MyDirectory/MyFile.raw.
{
"blobId": "2eb4af3bEXAMPLE",
"commitId": "317f8570EXAMPLE",
"treeId": "347a3408EXAMPLE"
}
Li Juan, a developer working in a repo named MyDemoRepo, wants to work on a new feature for an
upcoming version of a product. To keep her work separate from production-ready code, she creates a
branch off of the default branch and names it feature-randomizationfeature. She writes code,
makes commits, and pushes the new feature code into this branch. She wants other repository users
to review the code for quality before she merges her changes into the default branch. To do this, she
creates a pull request. The pull request contains the comparison between her working branch and the
branch of the code where she intends to merge her changes (in this case, the default branch). Other
users review her code and changes, adding comments and suggestions. She might update her working
branch multiple times with code changes in response to comments. Her changes are incorporated
into the pull request every time she pushes them to that branch in AWS CodeCommit. She might also
incorporate changes that have been made in the intended destination branch while the pull request is
open, so users can be sure they're reviewing all of the proposed changes in context. When she and her
reviewers are satisfied, she merges her code and closes the pull request.
Pull requests require two branches: a source branch that contains the code you want reviewed, and a
destination branch, where you merge the reviewed code. The source branch contains the AFTER commit,
which is the commit that contains the changes you want to merge into the destination branch. The
destination branch contains the BEFORE commit, which represents the "before" state of the code (before
the pull request branch is merged into the destination branch).
The pull request displays the differences between the tip of the source branch and the latest commit on
the destination branch when the pull request is created, so users can view and comment on the changes.
You can update the pull request in response to comments by committing and pushing changes to the
source branch.
When your code has been reviewed, you can close the pull request in one of several ways:
• Merge the branches locally and push your changes. This closes the request automatically.
• Use the AWS CodeCommit console to either close the pull request without merging or, if there are no
conflicts, to close and merge the branches.
• Use the AWS CLI.
• Make sure that you have committed and pushed the code changes you want reviewed to a branch (the
source branch).
• Set up notifications for your repository, so other users can be notified about the pull request and
changes to it. (This step is optional, but recommended.)
Pull requests are more effective when you've set up IAM users for your repository users in your AWS
account. It's easier to identify which user made which comment. IAM users also have the advantage
of being able to use Git credentials for repository access. For more information, see Step 1: Initial
Configuration for AWS CodeCommit (p. 6). You can use pull requests with other kinds of users, including
federated access users.
For information about working with other aspects of your repository in AWS CodeCommit, see Working
with Repositories (p. 75), Working with Files (p. 129), Working with Commits (p. 160), Working with
Branches (p. 190), and Working with User Preferences (p. 204).
Topics
• Create a Pull Request (p. 140)
• View Pull Requests in an AWS CodeCommit Repository (p. 143)
• Review a Pull Request (p. 146)
• Update a Pull Request (p. 153)
• Close a Pull Request in an AWS CodeCommit Repository (p. 156)
You can use the AWS CodeCommit console or the AWS CLI to create pull requests for your repository.
Topics
• Create a Pull Request (Console) (p. 140)
• Create a Pull Request (AWS CLI) (p. 142)
5. In Create pull request, in Source, choose the branch that contains the changes you want reviewed.
6. In Destination, choose the branch where you intend to merge your code changes when the pull
request is closed.
7. Choose Compare. A comparison runs on the two branches, and the differences between them are
displayed. An analysis is also performed to determine whether the two branches can be merged
automatically when the pull request is closed.
8. Review the comparison details and the changes to be sure that the pull request contains the changes
and commits you want reviewed. If not, adjust your choices for source and destination branches, and
choose Compare again.
9. When you are satisfied with the comparison results for the pull request, in Title, enter a short
but descriptive title for this review. This is the title that appears in the list of pull requests for the
repository.
10. (Optional) In Description, enter details about this review and any other useful information for
reviewers.
11. Choose Create.
Your pull request appears in the list of pull requests for the repository. If you configured
notifications (p. 84), subscribers to the Amazon SNS topic receive an email to inform them of the newly
created pull request.
To use the AWS CLI to create a pull request in an AWS CodeCommit repository:
For example, to create a pull request named My Pull Request with a description of Please
review these changes by Tuesday that targets the MyNewBranch source branch and is to be
merged to the default branch master in an AWS CodeCommit repository named MyDemoRepo:
API Version 2015-04-13
142
AWS CodeCommit User Guide
View Pull Requests
{
"pullRequest": {
"authorArn": "arn:aws:iam::111111111111:user/Jane_Doe",
"clientRequestToken": "123Example",
"creationDate": 1508962823.285,
"description": "Please review these changes by Tuesday",
"lastActivityDate": 1508962823.285,
"pullRequestId": "42",
"pullRequestStatus": "OPEN",
"pullRequestTargets": [
{
"destinationCommit": "5d036259EXAMPLE",
"destinationReference": "refs/heads/master",
"mergeMetadata": {
"isMerged": false,
},
"repositoryName": "MyDemoRepo",
"sourceCommit": "317f8570EXAMPLE",
"sourceReference": "refs/heads/MyNewBranch"
}
],
"title": "My Pull Request"
}
}
Topics
• View Pull Requests (Console) (p. 143)
• View Pull Requests (AWS CLI) (p. 144)
5. To change the display filter, choose from the list of available filters:
• Open pull requests (default): Displays all pull requests with a status of Open.
• All pull requests: Displays all pull requests.
• Closed pull requests: Displays all pull requests with a status of Closed.
• My pull requests: Displays all pull requests that you created, regardless of the status. It does not
display reviews that you have commented on or otherwise participated in.
• My open pull requests: Displays all pull requests that you created with a status of Open.
• My closed pull requests: Displays all pull requests that you created with a status of Closed.
6. When you find a pull request in the displayed list that you would like to view, choose it.
Follow these steps to use the AWS CLI to view pull requests in an AWS CodeCommit repository.
1. To view a list of pull requests in a repository, run the list-pull-requests command, specifying:
• The name of the AWS CodeCommit repository where you want to view pull requests (with the --
repository-name option).
• (Optional) The status of the pull request (with the --pull-request-status option).
• (Optional) The Amazon Resource Name (ARN) of the IAM user who created the pull request (with
the --author-arn option).
• (Optional) An enumeration token that can be used to return batches of results (with the --next-
token option)
• (Optional) A limit on the number of returned results per request (with the --max-results option).
API Version 2015-04-13
144
AWS CodeCommit User Guide
View Pull Requests (AWS CLI)
For example, to list pull requests created by an IAM user with the ARN
arn:aws:iam::111111111111:user/Li_Juan and the status of CLOSED in an AWS CodeCommit
repository named MyDemoRepo:
{
"nextToken": "",
"pullRequestIds": ["2","12","16","22","23","35","30","39","47"]
}
Pull request IDs are displayed in the order of most recent activity.
2. To view details of a pull request, run the get-pull-request command with the --pull-request-id
option, specifying the ID of the pull request. For example, to view information about a pull request
with the ID of 42:
{
"pullRequest": {
"authorArn": "arn:aws:iam::111111111111:user/Jane_Doe",
"title": "Pronunciation difficulty analyzer"
"pullRequestTargets": [
{
"destinationReference": "refs/heads/master",
"destinationCommit": "5d036259EXAMPLE",
"sourceReference": "refs/heads/jane-branch"
"sourceCommit": "317f8570EXAMPLE",
"repositoryName": "MyDemoRepo",
"mergeMetadata": {
"isMerged": false,
},
}
],
"lastActivityDate": 1508442444,
"pullRequestId": "42",
"clientRequestToken": "123Example",
"pullRequestStatus": "OPEN",
"creationDate": 1508962823,
"description": "A code review of the new feature I just added to the service.",
}
}
3. To view events in a pull request, run the describe-pull-request-events command with the --pull-
request-id option, specifying the ID of the pull request. For example, to view the events for a pull
request with the ID of 8:
{
"pullRequestEvents": [
{
"pullRequestId": "8",
"pullRequestEventType": "PULL_REQUEST_CREATED",
"eventDate": 1510341779.53,
"actor": "arn:aws:iam::111111111111:user/Zhang_Wei"
},
{
"pullRequestStatusChangedEventMetadata": {
"pullRequestStatus": "CLOSED"
},
"pullRequestId": "8",
"pullRequestEventType": "PULL_REQUEST_STATUS_CHANGED",
"eventDate": 1510341930.72,
"actor": "arn:aws:iam::111111111111:user/Jane_Doe"
}
]
}
4. To view whether there are any merge conflicts for a pull request, run the get-merge-conflicts
command, specifying:
• The name of the AWS CodeCommit repository (with the --repository-name option).
• The branch, tag, HEAD, or other fully qualified reference for the source of the changes to use in
the merge evaluation (with the --source-commit-specifier option).
• The branch, tag, HEAD, or other fully qualified reference for the destination of the changes to use
in the merge evaluation (with the --destination-commit-specifier option).
• The merge option to use (with the --merge-option option)
For example, to view whether there are any merge conflicts between the tip of a source branch
named my-feature-branch and a destination branch named master in a repository named
MyDemoRepo:
{
"destinationCommitId": "fac04518EXAMPLE",
"mergeable": false,
"sourceCommitId": "16d097f03EXAMPLE"
}
You can use the AWS CLI to comment on a pull request and reply to comments. To review the changes,
you must use the git diff command or a diff tool.
Topics
• Review a Pull Request (Console) (p. 147)
• Review Pull Requests (AWS CLI) (p. 150)
• To add a general comment, in Comments on changes, in New comment, enter a comment and
then choose Save. You can use Markdown, or you can enter your comment in plaintext.
• To add a comment to a file in the commit, in Changes, find the name of the file. Choose the
comment bubble that appears next to the file name , enter a comment, and then choose
Save.
• To add a comment to a changed line in the pull request, in Changes, go to the line you want to
comment on. Choose the comment bubble , enter a comment, and then choose Save.
If notifications (p. 84) are configured, the user who created the pull request receives email about your
comments. You receive email if a user replies to your comments or if the pull request is updated.
To use the AWS CLI to review pull requests in an AWS CodeCommit repository:
• The full commit ID of the commit in the destination branch where the pull request will be merged
(with the --before-commit-id option).
• The full commit ID of the commit in the source branch that is the current tip of the branch for the
pull request when you post the comment (with the --after-commit-id option).
• A unique, client-generated idempotency token (with the --client-request-token option).
• The content of your comment (with the --content option).
• A list of location information about where to place the comment, including:
• The name of the file being compared, including its extension and subdirectory, if any (with the
filePath attribute).
• The line number of the change in a compared file (with the filePosition attribute).
• Whether the comment on the change is "before" or "after" in the comparison between the
source and destination branches (with the relativeFileVersion attribute).
For example, to add the comment "These don't appear to be used anywhere. Can we
remove them?" on the change to the ahs_count.py file in a pull request with the ID of 47 in a
repository named MyDemoRepo:
{
"afterBlobId": "1f330709EXAMPLE",
"afterCommitId": "5d036259EXAMPLE",
"beforeBlobId": "80906a4cEXAMPLE",
"beforeCommitId": "317f8570EXAMPLE",
"comment": {
"authorArn": "arn:aws:iam::111111111111:user/Saanvi_Sarkar",
"clientRequestToken": "123Example",
"commentId": "abcd1234EXAMPLEb5678efgh",
"content": "These don't appear to be used anywhere. Can we remove
them?",
"creationDate": 1508369622.123,
"deleted": false,
"CommentId": "",
"lastModifiedDate": 1508369622.123
}
"location": {
"filePath": "ahs_count.py",
"filePosition": 367,
"relativeFileVersion": "AFTER"
},
"repositoryName": "MyDemoRepo",
"pullRequestId": "47"
}
2. To view comments for a pull request, run the get-comments-for-pull-request command, specifying:
• The name of the AWS CodeCommit repository (with the --repository-name option).
• The full commit ID of the commit in the source branch that was the tip of the branch at the time
the comment was made (with the --after-commit-id option).
• The full commit ID of the commit in the destination branch that was the tip of the branch at the
time the pull request was created (with the --before-commit-id option).
API Version 2015-04-13
151
AWS CodeCommit User Guide
Review Pull Requests (AWS CLI)
• (Optional) An enumeration token to return the next batch of the results (with the --next-token
option).
• (Optional) A non-negative integer to limit the number of returned results (with the --max-
results option).
For example, to view comments for a pull request in a repository named MyDemoRepo:
{
"commentsForPullRequestData": [
{
"afterBlobId": "1f330709EXAMPLE",
"afterCommitId": "5d036259EXAMPLE",
"beforeBlobId": "80906a4cEXAMPLE",
"beforeCommitId": "317f8570EXAMPLE",
"comments": [
{
"authorArn": "arn:aws:iam::111111111111:user/Saanvi_Sarkar",
"clientRequestToken": "",
"commentId": "abcd1234EXAMPLEb5678efgh",
"content": "These don't appear to be used anywhere. Can we remove
them?",
"creationDate": 1508369622.123,
"deleted": false,
"lastModifiedDate": 1508369622.123
},
{
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "",
"commentId": "442b498bEXAMPLE5756813",
"content": "Good catch. I'll remove them.",
"creationDate": 1508369829.104,
"deleted": false,
"commentId": "abcd1234EXAMPLEb5678efgh",
"lastModifiedDate": 150836912.273
}
],
"location": {
"filePath": "ahs_count.py",
"filePosition": 367,
"relativeFileVersion": "AFTER"
},
"repositoryName": "MyDemoRepo",
"pullRequestId": "42"
}
],
"nextToken": "exampleToken"
}
3. To post a reply to a comment in a pull request, run the post-comment-reply command, specifying:
• The system-generated ID of the comment to which you want to reply (with the --in-reply-to
option).
• A unique, client-generated idempotency token (with the --client-request-token option).
• The content of your reply (with the --content option).
For example, to add the reply "Good catch. I'll remove them." to the comment with the
system-generated ID of abcd1234EXAMPLEb5678efgh:
{
"comment": {
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "123Example",
"commentId": "442b498bEXAMPLE5756813",
"content": "Good catch. I'll remove them.",
"creationDate": 1508369829.136,
"deleted": false,
"CommentId": "abcd1234EXAMPLEb5678efgh",
"lastModifiedDate": 150836912.221
}
}
• You want users to review code changes you made to the source branch code in response to comments
in the pull request.
• One or more commits have been made to the destination branch since the pull request was created.
You want to incorporate those changes into the source branch (forward integration). This changes the
state of the pull request to Mergeable and enables the merging and closing of the pull request from
the console.
You can use the AWS CodeCommit console or the AWS CLI to update the title or description of a pull
request. You might want to update the pull request because:
• Other users don't understand the description, or the original title is misleading.
• You want the title or description to reflect changes made to the source branch of an open pull request.
Topics
• Update a Pull Request (Git) (p. 153)
• Update a Pull Request (Console) (p. 154)
• Update Pull Requests (AWS CLI) (p. 155)
• Forward-integrate changes made in the destination branch into the source branch.
• Make sure that all the changes to be merged into the destination branch have been reviewed in the
pull request.
You make the changes on your local computer, and then commit and push them to the source branch. If
notifications are configured for the repository (p. 84), users subscribed to the topic receive emails when
you push changes to the source branch of an open pull request.
1. From the local repo on your computer, at the terminal or command line, make sure you have pulled
the latest changes to the repository, and then run the git checkout command, specifying the source
branch of the pull request. For example, to check out a source branch of a pull request named
pullrequestbranch:
2. Make any changes you want reviewed. For example, if you want to change the code in the
source branch in responses to user comments, edit the files with those changes. If you want to
integrate changes that have been made to the destination branch into the source branch (forward
integration), run the git merge command, specifying the destination branch, to merge those
changes into the source branch.
Tip
You might want to use diff tool or merge tool software to help view and choose the
changes you want integrated into a source branch.
3. After you have made your changes, run the git add and git commit commands to stage and commit
them.
Tip
You can run these commands separately, or you can use the -a option to add changed files
to a commit automatically. For example, you could run a command similar to the following:
For more information, see Basic Git Commands (p. 291) or consult your Git documentation.
4. Run the git push command to push your changes to AWS CodeCommit. Your pull request is updated
with the changes you made to the source branch.
To use the AWS CLI to update pull requests in an AWS CodeCommit repository:
1. To update the title of a pull request in a repository, run the update-pull-request-title command,
specifying:
For example, to update the title of a pull request with the ID of 47:
{
"pullRequest": {
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "",
"creationDate": 1508530823.12,
"description": "Review the latest changes and updates to the global variables.
I have updated this request with some changes, including removing some unused
variables.",
"lastActivityDate": 1508372657.188,
"pullRequestId": "47",
"pullRequestStatus": "OPEN",
"pullRequestTargets": [
{
"destinationCommit": "9f31c968EXAMPLE",
"destinationReference": "refs/heads/master",
"mergeMetadata": {
"isMerged": false,
},
"repositoryName": "MyDemoRepo",
"sourceCommit": "99132ab0EXAMPLE",
"sourceReference": "refs/heads/variables-branch"
}
],
"title": "Consolidation of global variables - updated review"
}
}
{
"pullRequest": {
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "",
"creationDate": 1508530823.155,
"description": "Updated the pull request to remove unused global variable.",
"lastActivityDate": 1508372423.204,
"pullRequestId": "47",
"pullRequestStatus": "OPEN",
"pullRequestTargets": [
{
"destinationCommit": "9f31c968EXAMPLE",
"destinationReference": "refs/heads/master",
"mergeMetadata": {
"isMerged": false,
},
"repositoryName": "MyDemoRepo",
"sourceCommit": "99132ab0EXAMPLE",
"sourceReference": "refs/heads/variables-branch"
}
],
"title": "Consolidation of global variables"
}
}
•
On your local computer, you can use the git merge command to merge the source branch into the
destination branch, and then push your merged code to the destination branch. This closes the
pull request automatically. The git merge command also allows you to choose the merge option or
strategy you use for the merge. This is the only option available to merge the branches if the pull
request status shows Resolve conflicts. For more information about git merge and merge options, see
git-merge or your Git documentation.
• In the console, you can close a pull request without merging the code. You might want to do this if you
want to use the git merge command to merge the branches manually, or if the code in the pull request
source branch isn't code you want merged into the destination branch. This is the only option available
if the code cannot be merged automatically. You see an advisory message to resolve conflicts, which
you must do on your local computer with the git merge command or a diff or merge tool.
•
In the console, you might be able to merge your source branch to the destination branch
automatically, which closes the pull request automatically. You see an advisory message that the pull
request is mergeable, and the Merge button in the pull request is active. When you choose Merge, the
merge is performed using the fast-forward merge option.
Note
The fast-forward option does not create a commit or commit message for the merge. If you
want a merge commit to appear in the history of the destination branch, you can choose not
to automatically merge the code as part of closing the pull request. Instead, you can manually
merge the branches using the git merge command with a different merge option.
• AWS CodeCommit closes a pull request automatically if either the source or destination branch of the
pull request is deleted.
• In the AWS CLI, you can update the status of a pull request from OPEN to CLOSED. This closes the pull
request. You can also use the AWS CLI to attempt to merge and close the pull request.
Topics
• Close a Pull Request (Console) (p. 157)
• Close Pull Requests (AWS CLI) (p. 158)
• Merge: This option, if available, closes the pull request and attempts to merge the code into
the destination branch using the fast-forward merge option. You can also optionally choose to
automatically delete the pull request source branch after the merge is successful. If the merge
attempt is not successful, the source branch is not deleted.
Note
The Merge option is available only if there are no merge conflicts detected between the
source and destination branches.
• Close pull request: This option closes the pull request without attempting to merge the source
branch into the destination branch. This option does not provide a way to delete the source
branch as part of closing the pull request, but you can do it yourself after the request is closed.
To use the AWS CLI to close pull requests in an AWS CodeCommit repository:
1. To update the status of a pull request in a repository from OPEN to CLOSED, run the update-pull-
request-status command, specifying:
For example, to update the status of a pull request with the ID of 42 to a status of CLOSED in an
AWS CodeCommit repository named MyDemoRepo:
{
"pullRequest": {
"authorArn": "arn:aws:iam::111111111111:user/Jane_Doe",
"clientRequestToken": "123Example",
"creationDate": 1508962823.165,
"description": "A code review of the new feature I just added to the service.",
"lastActivityDate": 1508442444.12,
"pullRequestId": "42",
"pullRequestStatus": "CLOSED",
"pullRequestTargets": [
{
"destinationCommit": "5d036259EXAMPLE",
"destinationReference": "refs/heads/master",
"mergeMetadata": {
"isMerged": false,
},
"repositoryName": "MyDemoRepo",
"sourceCommit": "317f8570EXAMPLE",
"sourceReference": "refs/heads/jane-branch"
}
],
"title": "Pronunciation difficulty analyzer"
}
}
For example, to merge and close a pull request with the ID of 47 and a source commit ID of
99132ab0EXAMPLE in a repository named MyDemoRepo:
{
"pullRequest": {
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "",
"creationDate": 1508530823.142,
"description": "Review the latest changes and updates to the global variables",
"lastActivityDate": 1508887223.155,
"pullRequestId": "47",
"pullRequestStatus": "CLOSED",
"pullRequestTargets": [
{
"destinationCommit": "9f31c968EXAMPLE",
"destinationReference": "refs/heads/master",
"mergeMetadata": {
"isMerged": true,
"mergedBy": "arn:aws:iam::111111111111:user/Mary_Major"
},
"repositoryName": "MyDemoRepo",
"sourceCommit": "99132ab0EXAMPLE",
"sourceReference": "refs/heads/variables-branch"
}
],
"title": "Consolidation of global variables"
}
}
• Review commits.
• View the history of commits in a graph.
• Compare a commit to its parent or to another specifier.
• Add comments to your commits and reply to comments made by others.
Before you can push commits to an AWS CodeCommit repository, you must set up your local computer to
connect to the repository. For the simplest method, see For HTTPS Users Using Git Credentials (p. 5).
For information about working with other aspects of your repository in AWS CodeCommit, see Working
with Repositories (p. 75), Working with Files (p. 129), Working with Pull Requests (p. 138) , Working with
Branches (p. 190), and Working with User Preferences (p. 204).
Topics
• Create a Commit in AWS CodeCommit (p. 161)
• View Commit Details in AWS CodeCommit (p. 163)
• Compare Commits in AWS CodeCommit (p. 170)
• Comment on a Commit in AWS CodeCommit (p. 175)
For example, in the local repo, create a file named bird.txt with the following text:
bird.txt
--------
Birds (class Aves or clade Avialae) are feathered, winged, two-legged, warm-blooded,
egg-laying vertebrates.
4. Run git status, which should indicate that bird.txt has not yet been included in any pending
commit:
...
Untracked files:
(use "git add <file>..." to include in what will be committed)
bird.txt
5. Run git add bird.txt to include the new file in the pending commit.
6. If you run git status again, you should see output similar to the following. It indicates that
bird.txt is now part of the pending commit or staged for commit:
...
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
7. To finalize the commit, run git commit with the -m option (for example, git commit -m "Adding
bird.txt to the repository.") The -m option creates the commit message.
8. If you run git status again, you should see output similar to the following. It indicates that the
commit is ready to be pushed from the local repo to the AWS CodeCommit repository:
...
nothing to commit, working directory clean
9. Before you push the finalized commit from the local repo to the AWS CodeCommit repository,
you can see what will be pushed by running git diff --stat remote-name/branch-name, where
remote-name is the nickname the local repo uses for the AWS CodeCommit repository and
branch-name is the name of the branch to compare.
Tip
To get the nickname, run git remote. To get a list of branch names, run git branch. An
asterisk (*) appears next to the current branch. You can also run git status to get the
current branch name.
Note
If you cloned the repository, from the perspective of the local repo, remote-name is not
the name of the AWS CodeCommit repository. When you clone a repository, remote-name
is set automatically to origin.
For example, git diff --stat origin/master would show output similar to the following:
bird.txt | 1 +
1 file changed, 1 insertion(+)
Of course, the output assumes you have already connected the local repo to the AWS CodeCommit
repository. (For instructions, see Connect to a Repository (p. 78).)
10. When you're ready to push the commit from the local repo to the AWS CodeCommit repository, run
git push remote-name branch-name, where remote-name is the nickname the local repo uses for
the AWS CodeCommit repository and branch-name is the name of the branch to push to the AWS
CodeCommit repository.
For example, running git push origin master would show output similar to the following:
For HTTPS:
For SSH:
Tip
If you add the -u option to git push (for example, git push -u origin master), then you only
need to run git push in the future because upstream tracking information has been set. To
get upstream tracking information, run git remote show remote-name (for example, git
remote show origin).
Viewing the history of commits for a branch might also help you understand the difference between
branches. If you use tagging, you can also quickly view the commit that was labeled with a specific tag
and the parents of that tagged commit. At the command line, you can use Git to view details about the
commits in a local repo or an AWS CodeCommit repository.
Topics
• Browse the Commit History of a Repository (p. 163)
• View a Graph of the Commit History of a Repository (p. 164)
4. To view the difference between a commit and its parent, and to see any comments on the
changes, choose the abbreviated commit ID. For more information, see Compare a Commit to Its
Parent (p. 170) and Comment on a Commit (p. 175). To view the difference between a commit
and any other commit specifier, including a branch, tag, or commit ID, see Compare Any Two Commit
Specifiers (p. 173).
5. Do one or more of the following:
• To view the date and time a change was made, hover over the commit date.
• To view the full commit ID, copy and then paste it into a text editor or other location. To copy it,
choose Copy ID.
• To view the code as it was at the time of a commit, choose Browse. The contents of the repository
as they were at the time of that commit is displayed in the Code view. The view selector button
displays the abbreviated commit ID instead of a branch or tag.
In the commit graph, the abbreviated commit ID and the subject for each commit message appears
next to that point in the graph.
Note
The graph can display up to 35 branches on a page. If there are more than 35 branches, the
graph is too complex to display. You can simplify the view in two ways:
• By using the view selector button to show the graph for a specific branch.
• By pasting a full commit ID into the search box to render the graph from that commit.
4. To render a new graph from a commit, choose the point in the graph that corresponds to that
commit. The view selector button changes to the abbreviated commit ID.
• The name of the AWS CodeCommit repository (with the --repository-name option).
• The full commit ID.
For example, to view information about a commit with the ID 317f8570EXAMPLE in an AWS
CodeCommit repository named MyDemoRepo:
• Information about the author of the commit (as configured in Git), including the date in time
stamp format and the coordinated universal time (UTC) offset.
• Information about the committer (as configured in Git) including the date in time stamp format
and the UTC offset.
• The ID of the Git tree where the commit exists.
• The commit ID of the parent commit.
• The commit message.
{
"commit": {
"additionalData": "",
"committer": {
"date": "1484167798 -0800",
"name": "Mary Major",
"email": "[email protected]"
},
"author": {
"date": "1484167798 -0800",
"name": "Mary Major",
"email": "[email protected]"
},
"treeId": "347a3408EXAMPLE",
"parents": [
"4c925148EXAMPLE"
],
"message": "Fix incorrect variable name"
}
}
• The name of the AWS CodeCommit repository (with the --repository-name option).
• The commit specifiers you want to get information about. Only --after-commit-specifier
is required. If you do not specify --before-commit-specifier, all files current as of the --
after-commit-specifier are shown.
For example, to view information about the differences between commits with the IDs
317f8570EXAMPLE and 4c925148EXAMPLE in an AWS CodeCommit repository named
MyDemoRepo:
• A list of differences, including the change type (A for added, D for deleted, or M for modified).
• The mode of the file change type.
• The ID of the Git blob object that contains the change.
{
API Version 2015-04-13
167
AWS CodeCommit User Guide
View Commit Details (Git)
"differences": [
{
"afterBlob": {
"path": "blob.txt",
"blobId": "2eb4af3bEXAMPLE",
"mode": "100644"
},
"changeType": "M",
"beforeBlob": {
"path": "blob.txt",
"blobId": "bf7fcf28fEXAMPLE",
"mode": "100644"
}
}
]
}
• The name of the AWS CodeCommit repository (with the --repository-name option).
• The ID of the Git blob (with the --blob-id option).
For example, to view information about a Git blob with the ID of 2eb4af3bEXAMPLE in an AWS
CodeCommit repository named MyDemoRepo:
For example, the output of the previous command might be similar to the following:
{
"content": "QSBCaW5hcnkgTGFyToEXAMPLE="
}
To show the changes for the most recent commit to a repository, run the git show command.
git show
commit 4f8c6f9d
Author: Mary Major <[email protected]>
Date: Mon May 23 15:56:48 2016 -0700
Added bumblebee.txt
Note
In this and the following examples, commit IDs have been abbreviated. The full commit IDs are
not shown.
To view the changes that occurred, use the git show command with the commit ID:
commit 94ba1e60
Author: John Doe <[email protected]>
Date: Mon May 23 15:39:14 2016 -0700
Added horse.txt
To see the differences between two commits, run the git diff command and include the two commit IDs.
In this example, the difference between the two commits is that two files were added. The command
produces output similar to the following:
To use Git to view details about the commits in a local repo, run the git log command:
git log
commit 94ba1e60
Author: John Doe <[email protected]>
Date: Mon May 23 15:39:14 2016 -0700
Added horse.txt
commit 4c925148
Author: Jane Doe <[email protected]>
Date: Mon May 22 14:54:55 2014 -0700
To show only commit IDs and messages, run the git log --pretty=oneline command:
Topics
• Compare a Commit to Its Parent (p. 170)
• Compare Any Two Commit Specifiers (p. 173)
You can show changes side by side (Split view) or inline (Unified view). You can also hide or show
white space changes. You can also add comments. For more information, see Comment on a
Commit (p. 175).
Note
Your preferences for viewing code and other console settings are saved as browser
cookies whenever you change them. For more information, see Working with User
Preferences (p. 204).
Note
Depending on line ending style, your code editor, and other factors, you might see entire
lines added or deleted instead of specific changes in a line. The level of detail matches
what's returned in the git show or git diff commands.
5. To compare a commit to its parent, from the Commit visualizer tab, choose the abbreviated commit
ID. The commit details, including the changes between the commit and its parent, are displayed.
• To compare the tip of a branch, choose the branch name from the list. This selects the most recent
commit from that branch for the comparison.
• To compare a commit with a specific tag associated with it, choose the tag name from the list, if
any. This selects the tagged commit for the comparison.
• To compare a specific commit, enter or paste the commit ID in the box. To get the full commit ID,
choose Commits in the navigation bar, and copy the commit ID from the list. On the Compare
commits page, paste the full commit ID in the text box, and choose Use commit ID.
You can show differences side by side (Split view) or inline (Unified view). You can also hide or show
white space changes.
6. To clear your comparison choices, choose Cancel.
You can comment on an overall commit, a file in a commit, or a specific line or change in a file.
Note
For best results, use commenting when you are signed in as an IAM user. The commenting
functionality is not optimized for users who sign in with root account credentials, federated
access, or temporary credentials.
Topics
• View Comments on a Commit in a Repository (p. 176)
• Add and Reply to Comments on a Commit in a Repository (p. 176)
• View, Add, Update, and Reply to Commments (AWS CLI) (p. 181)
The page for that commit is displayed, along with any comments.
The page for that commit is displayed, along with any comments.
4. To add a comment, do one of the following:
• To add a general comment, in Comments on changes, enter your comment, and then choose
Save. You can use Markdown, or you can enter your comment in plaintext.
• To add a comment to a file in the commit, find the name of the file. Choose Comment on file,
enter your comment, and then choose Save.
• To add a comment to a changed line in the commit, go to the line where the change appears.
Choose the comment bubble , enter your comment, and then choose Save.
Note
You can edit your comment after you have saved it, but you cannot delete it from the AWS
CodeCommit console. Consider using the Preview markdown mode for your comment
before you save it.
5. To reply to comments on a commit, choose Reply.
4. Use the Destination and Source fields to compare two commit specifiers. Use the drop-down lists or
paste in commit IDs. Choose Compare.
•
To add comments to files or lines, choose the comment bubble .
• The name of the AWS CodeCommit repository (with the --repository-name option).
• The full commit ID of the 'after' commit, to establish the directionality of the comparison (with the
--after-commit-id option).
• The full commit ID of the 'before' commit, to establish the directionality of the comparison (with
the --before-commit-id option).
• (Optional) An enumeration token to return the next batch of the results (with the --next-token
option).
• (Optional) A non-negative integer to limit the number of returned results (with the --max-
results option).
For example, to view comments made on the comparison between two commits in a repository
named MyDemoRepo:
{
"commentsForComparedCommitData": [
{
"afterBlobId": "1f330709EXAMPLE",
"afterCommitId": "317f8570EXAMPLE",
"beforeBlobId": "80906a4cEXAMPLE",
"beforeCommitId": "6e147360EXAMPLE",
"comments": [
{
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "123Example",
"commentId": "ff30b348EXAMPLEb9aa670f",
"content": "Whoops - I meant to add this comment to the line, not the
file, but I don't see how to delete it.",
"creationDate": 1508369768.142,
"deleted": false,
"CommentId": "123abc-EXAMPLE",
"lastModifiedDate": 1508369842.278
},
{
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "123Example",
"commentId": "553b509bEXAMPLE56198325",
"content": "Can you add a test case for this?",
"creationDate": 1508369612.240,
"deleted": false,
"commentId": "456def-EXAMPLE",
"lastModifiedDate": 1508369612.240
}
],
"location": {
"filePath": "cl_sample.js",
"filePosition": 1232,
"relativeFileVersion": "after"
},
"repositoryName": "MyDemoRepo"
}
],
"nextToken": "exampleToken"
}
{
"comment": {
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "123Example",
"commentId": "ff30b348EXAMPLEb9aa670f",
"content": "Whoops - I meant to add this comment to the line, but I don't see how
to delete it.",
"creationDate": 1508369768.142,
"deleted": false,
"commentId": "",
"lastModifiedDate": 1508369842.278
}
}
Note
You can only delete the content of a comment that you created.
2. If successful, this command produces output similar to the following:
{
"comment": {
"creationDate": 1508369768.142,
"deleted": true,
"lastModifiedDate": 1508369842.278,
"clientRequestToken": "123Example",
"commentId": "ff30b348EXAMPLEb9aa670f",
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan"
}
}
For example, to add the comment "Can you add a test case for this?" on the change
to the cl_sample.js file in the comparison between two commits in a repository named
MyDemoRepo:
{
"afterBlobId": "1f330709EXAMPLE",
"afterCommitId": "317f8570EXAMPLE",
"beforeBlobId": "80906a4cEXAMPLE",
"beforeCommitId": "6e147360EXAMPLE",
"comment": {
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "",
"commentId": "553b509bEXAMPLE56198325",
"content": "Can you add a test case for this?",
API Version 2015-04-13
183
AWS CodeCommit User Guide
View, Add, Update, and Reply to Commments (AWS CLI)
"creationDate": 1508369612.203,
"deleted": false,
"commentId": "abc123-EXAMPLE",
"lastModifiedDate": 1508369612.203
},
"location": {
"filePath": "cl_sample.js",
"filePosition": 1232,
"relativeFileVersion": "AFTER"
},
"repositoryName": "MyDemoRepo"
}
For example, to add the content "Fixed as requested. I'll update the pull request."
to a comment with an ID of 442b498bEXAMPLE5756813 :
{
"comment": {
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "",
"commentId": "442b498bEXAMPLE5756813",
"content": "Fixed as requested. I'll update the pull request.",
"creationDate": 1508369929.783,
"deleted": false,
"lastModifiedDate": 1508369929.287
}
}
• The system-generated ID of the comment to which you want to reply (with the --in-reply-to
option).
• A unique, client-generated idempotency token (with the --client-request-token option).
• The content of your reply (with the --content option).
For example, to add the reply "Good catch. I'll remove them." to the comment with the
system-generated ID of abcd1234EXAMPLEb5678efgh:
{
"comment": {
"authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
"clientRequestToken": "123Example",
"commentId": "442b498bEXAMPLE5756813",
"content": "Good catch. I'll remove them.",
"creationDate": 1508369829.136,
"deleted": false,
"CommentId": "abcd1234EXAMPLEb5678efgh",
"lastModifiedDate": 150836912.221
}
}
In these steps, we assume that you have already connected the local repo to the AWS CodeCommit
repository. For instructions, see Connect to a Repository (p. 78).
1. Run the git tag new-tag-name commit-id command, where new-tag-name is the new tag's name
and commit-id is the ID of the commit to associate with the tag.
For example, the following command creates a tag named beta and associates it with the commit
ID dc082f9a...af873b88:
2. To push the new tag from the local repo to the AWS CodeCommit repository, run the git
push remote-name new-tag-name command, where remote-name is the name of the AWS
CodeCommit repository and new-tag-name is the name of the new tag.
For example, to push a new tag named beta to an AWS CodeCommit repository named origin:
Note
To push all new tags from your local repo to the AWS CodeCommit repository, run git push --
tags.
To ensure your local repo is updated with all of the tags in the AWS CodeCommit repository, run
git fetch followed by git fetch --tags.
You can use the AWS CodeCommit console to view information about tags in your repository, including
the date and commit message of the commit referenced by each tag. From the console, you can compare
the commit referenced by the tag with the head of the default branch of your repository. Like any other
commit, you can also view the code at the point of that tag.
You can also use Git from your terminal or command line to view details about tags in a local repo.
Topics
• View Tag Details (Console) (p. 186)
• View Tag Details (Git) (p. 187)
Note
You can adjust the number of tags displayed on the Tags page by changing the number of
tags per page.
4. Do one of the following:
• To view the code as it was at that tagged commit, choose the tag name.
• To view details of the commit, including the full commit message, committer, and author, choose
the abbreviated commit ID.
Note
To ensure that your local repo is updated with all of the tags in the AWS CodeCommit
repository, run git fetch followed by git fetch --tags.
In the following steps, we assume that you have already connected the local repo to AWS CodeCommit
repository. For instructions, see Connect to a Repository (p. 78).
git tag
beta
release
Note
If no tags have been defined, git tag returns nothing.
commit 317f8570...ad9e3c09
Author: John Doe <[email protected]>
Date: Tue Sep 23 13:49:51 2014 -0700
Added horse.txt
Note
To exit the output of the tag information, type :q.
2. If successful, this command produces as output a list of the tags in the AWS CodeCommit repository:
129ce87a...70fbffba refs/tags/beta
785de9bd...59b402d8 refs/tags/release
If no tags have been defined, git ls-remote --tags returns a blank line.
These steps are written with the assumption that you have already connected the local repo to the AWS
CodeCommit repository. For instructions, see Connect to a Repository (p. 78).
1. To delete the tag from the local repo, run the git tag -d tag-name command where tag-name is
the name of the tag you want to delete.
Tip
To get a list of tag names, run git tag.
2. To delete the tag from the AWS CodeCommit repository, run the git push remote-name --delete
tag-name command where remote-name is the nickname the local repo uses for the AWS
CodeCommit repository and tag-name is the name of the tag you want to delete from the AWS
CodeCommit repository.
Tip
To get a list of AWS CodeCommit repository names and their URLs, run the git remote -v
command.
For example, to delete a tag named beta in the AWS CodeCommit repository named origin:
In AWS CodeCommit, you can change the default branch for your repository. This default branch is
the one used as the base or default branch in local repos when users clone the repository. You can
also create and delete branches and view details about a branch. You can quickly compare differences
between a branch and the default branch (or any two branches). To view the history of branches and
merges in your repository, you can use the Commit Visualizer (p. 164).
For information about working with other aspects of your repository in AWS CodeCommit, see Working
with Repositories (p. 75), Working with Files (p. 129), Working with Pull Requests (p. 138), Working with
Commits (p. 160), and Working with User Preferences (p. 204).
Topics
• Create a Branch in AWS CodeCommit (p. 191)
• Limit Pushes and Merges to Branches in AWS CodeCommit (p. 194)
• View Branch Details in AWS CodeCommit (p. 196)
Topics
• Create a Branch (Console) (p. 191)
• Use Git to Create a Branch (p. 192)
• Create a Branch (AWS CLI) (p. 193)
In Branch name, enter a name for the branch. In Branch from, choose a branch or tag from the list,
or paste a commit ID. Choose Create branch.
These steps are written with the assumption that you have already connected the local repo to the AWS
CodeCommit repository. For instructions, see Connect to a Repository (p. 78).
1. Create a branch in your local repo by running the git checkout -b new-branch-name command,
where new-branch-name is the name of the new branch.
For example, the following command creates a branch named MyNewBranch in the local repo:
2. To push the new branch from the local repo to the AWS CodeCommit repository, run the git push
command, specifying both the remote-name and the new-branch-name.
For example, to push a new branch in the local repo named MyNewBranch to the AWS CodeCommit
repository with the nickname origin:
Note
If you add the -u option to git push (for example, git push -u origin master), then in the future
you can run git push without remote-name branch-name. Upstream tracking information is
set. To get upstream tracking information, run git remote show remote-name (for example, git
remote show origin).
To see a list of all of your local and remote tracking branches, run git branch --all.
To set up a branch in the local repo that is connected to an existing branch in the AWS
CodeCommit repository, run git checkout remote-branch-name.
Follow these steps to use the AWS CLI to create a branch in an AWS CodeCommit repository and then
push that branch to the AWS CodeCommit repository.
• The name of the AWS CodeCommit repository where the branch is created (with the --repository-
name option).
Note
To get the name of the AWS CodeCommit repository, run the list-repositories (p. 110)
command.
• The name of the new branch (with the --branch-name option).
• The ID of the commit to which the new branch points (with the --commit-id option).
For example, to create a branch named MyNewBranch that points to commit ID 317f8570EXAMPLE
in an AWS CodeCommit repository named MyDemoRepo:
For example, to update the list of available branches for the AWS CodeCommit repository with the
nickname origin:
Note
Alternatively, you can run the git fetch command. You can also view all remote branches by
running git branch --all, but until you update the list of your local repo, the remote branch
you created does not appear in the list.
For more options, see your Git documentation.
3. To set up a branch in the local repo that is connected to the new branch in the AWS CodeCommit
repository, run git checkout remote-branch-name.
Note
To get a list of AWS CodeCommit repository names and their URLs, run the git remote -v
command.
Topics
• Configure an IAM Policy to Limit Pushes and Merges to a Branch (p. 194)
• Apply the IAM Policy to an IAM Group or Role (p. 195)
• Test the Policy (p. 196)
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the navigation pane, choose Policies.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"codecommit:GitPush",
"codecommit:DeleteBranch",
"codecommit:PutFile",
"codecommit:MergePullRequestByFastForward"
],
"Resource": "arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo",
"Condition": {
"StringEqualsIfExists": {
"codecommit:References": [
"refs/heads/master",
"refs/heads/prod"
]
},
"Null": {
"codecommit:References": false
}
}
}
]
}
Branches in Git are simply pointers (references) to the SHA-1 value of the head commit, which is
why the condition uses References. The Null statement is required in any policy whose effect is
Deny and where GitPush is one of the actions. This is required because of the way Git and git-
receive-pack work when pushing changes from a local repo to AWS CodeCommit.
Tip
To create a policy that applies to all branches named master in all repositories in an AWS
account, change the value of Resource from a repository ARN to an asterisk (*).
5. Choose Review policy. Correct any errors in your policy statement, and then continue to Create
policy.
6. When the JSON is validated, the Create policy page is displayed. A warning appears in the Summary
section, advising you that this policy does not grant permissions. This is expected.
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the navigation pane, if you want to apply the policy to an IAM group, choose Groups.If you want
to apply the policy to a role that users assume, choose Role. Choose the name of the group or role.
3. On the Permissions tab, choose Attach Policy.
4. Select the conditional policy you created from the list of policies, and then choose Attach policy.
• Sign in to the AWS CodeCommit console with an IAM user who is either a member of an IAM group
that has the policy applied, or assumes a role that has the policy applied. In the console, add a file on
the branch where the restrictions apply. You should see an error message when you attempt to save or
upload a file to that branch. Add a file to a different branch. The operation should succeed.
• Sign in to the AWS CodeCommit console with an IAM user who is either a member of an IAM group
that has the policy applied, or assumes a role that has the policy applied. Create a pull request that
merges to the branch where the restrictions apply. You should be able to create the pull request, but
get an error if you try to merge it.
• From the terminal or command line, create a commit on the branch where the restrictions apply,
and then push that commit to the AWS CodeCommit repository. You should see an error message.
Commits and pushes made from other branches should work as usual.
Topics
• View Branch Details (Console) (p. 196)
• View Branch Details (Git) (p. 197)
• View Branch Details (AWS CLI) (p. 198)
4. The name of the branch used as the default for the repository is displayed next to Default branch.
To view details about the most recent commit to a branch, choose the branch, and then choose View
last commit. To view the files and code in a branch, choose the branch name.
The following steps are written with the assumption that you have already connected the local repo to
the AWS CodeCommit repository. For instructions, see Connect to a Repository (p. 78).
MyNewBranch
* master
remotes/origin/MyNewBranch
remotes/origin/master
The asterisk (*) appears next to the currently open branch. The entries after that are remote tracking
references.
Tip
git branch shows local branches.
To use the AWS CLI to view details about the branches in an AWS CodeCommit repository, run one or
more of the following commands:
For example, to view details about the branches in an AWS CodeCommit repository named
MyDemoRepo:
2. If successful, this command outputs a branchNameList object, with an entry for each branch.
{
"branches": [
"MyNewBranch",
"master"
]
}
For example, to view information about a branch named MyNewBranch in an AWS CodeCommit
repository named MyDemoRepo:
2. If successful, this command outputs the name of the branch and the ID of the last commit made to
the branch.
{
"branch": {
"branchName": "MyNewBranch",
"commitID": "317f8570EXAMPLE"
}
}
Topics
• Compare a Branch to the Default Branch (p. 199)
• Compare Two Specific Branches (p. 199)
Note
If you are signed in as an IAM user, you can configure and save your preferences for
viewing code and other console settings. For more information, see Working with User
Preferences (p. 204).
Topics
• Use the AWS CodeCommit Console to Change the Default Branch (p. 200)
• Use the AWS CLI to Change Branch Settings (p. 201)
2. In Repositories, choose the name of the repository where you want to change settings.
3. In the navigation pane, choose Settings.
4. In Default branch, choose the branch drop-down list and choose a different branch. Choose Save.
To use the AWS CLI to change a repository's branch settings in an AWS CodeCommit repository, run the
following command:
• The name of the AWS CodeCommit repository where the default branch will be updated (with the
--repository-name option).
Tip
To get the name of the AWS CodeCommit repository, run the list-repositories (p. 110)
command.
• The name of the new default branch (with the --default-branch-name option).
Tip
To get the name of the branch, run the list-branches (p. 198) command.
2. For example, to change the default branch to MyNewBranch in an AWS CodeCommit repository
named MyDemoRepo:
Deleting a branch does not delete any commits, but it does delete all references to the commits in that
branch. If you delete a branch that contains commits that have not been merged into another branch in
the repository, you cannot retrieve those commits unless you have their full commit IDs.
Note
You cannot use the instructions in this topic to delete a repository's default branch. If you
want to delete the default branch, you must create a branch, make the new branch the default
branch, and then delete the old branch. For more information, see Create a Branch (p. 191)
and Change Branch Settings (p. 200).
Topics
• Delete a Branch (Console) (p. 202)
• Delete a Branch (AWS CLI) (p. 202)
• Delete a Branch (Git) (p. 202)
• The name of the AWS CodeCommit repository where the branch will be deleted (with the --
repository-name option).
Tip
To get the name of the AWS CodeCommit repository, run the list-repositories (p. 110)
command.
• The name of the branch to delete (with the branch-name option).
Tip
To get the name of the branch, run the list-branches (p. 198) command.
2. For example, to delete a branch named MyNewBranch in an AWS CodeCommit repository named
MyDemoRepo:
This command returns information about the deleted branch, including the name of the deleted
branch and the full commit ID of the commit that was the head of the branch. For example:
"deletedBranch": {
"branchName": "MyNewBranch",
"commitId": "317f8570EXAMPLE"
}
These steps are written with the assumption that you have already connected the local repo to the AWS
CodeCommit repository. For instructions, see Connect to a Repository (p. 78).
1. To delete the branch from the local repo, run the git branch -D branch-name command where
branch-name is the name of the branch you want to delete.
Tip
To get a list of branch names, run git branch --all.
2. To delete the branch from the AWS CodeCommit repository, run the git push remote-name --
delete branch-name command where remote-name is the nickname the local repo uses for the
AWS CodeCommit repository and branch-name is the name of the branch you want to delete from
the AWS CodeCommit repository.
Tip
To get a list of AWS CodeCommit repository names and their URLs, run the git remote -v
command.
For example, to delete a branch named MyNewBranch in the AWS CodeCommit repository named
origin:
Tip
This command does not delete a branch if it is the default branch.
• When viewing changes in code, whether to use Unified or Split view, and whether to show or hide
whitespace changes.
• When viewing, editing, or authoring code, whether to use a light background or a dark background in
the code editor window.
There is no one page for setting your preferences. Instead, wherever you change a preference in the
console, such as how you prefer to view code changes, that change is saved and applied wherever
appropriate.
The following topics show you some of the ways you can migrate a repository. Your steps might vary,
depending on the type, style, or complexity of your repository and the decisions you make about
what and how you want to migrate. For very large repositories, you might want to consider migrating
incrementally (p. 220).
Note
You can migrate to AWS CodeCommit from other version control systems, such as Perforce,
Subversion, or TFS, but you must first migrate to Git.
For more options, see your Git documentation.
Alternatively, you can review the information about migrating to Git in the Pro Git book by Scott
Chacon and Ben Straub.
Topics
• Migrate a Git Repository to AWS CodeCommit (p. 205)
• Migrate Local or Unversioned Content to AWS CodeCommit (p. 213)
• Migrate a Repository Incrementally (p. 220)
Topics
• Step 0: Setup Required for Access to AWS CodeCommit (p. 206)
• Step 1: Create an AWS CodeCommit Repository (p. 208)
• Step 2: Clone the Repository and Push to the AWS CodeCommit Repository (p. 210)
• Step 3: View Files in AWS CodeCommit (p. 211)
• Step 4: Share the AWS CodeCommit Repository (p. 211)
If you are already set up for AWS CodeCommit, you can skip ahead to Step 1: Create an AWS
CodeCommit Repository (p. 208).
After you have selected the policy you want to attach, choose Next: Review to review the list of
policies that will be attached to the IAM user. If the list is correct, choose Add permissions.
For more information about AWS CodeCommit managed policies and sharing access to repositories
with other groups and users, see Share a Repository (p. 81) and Authentication and Access Control
for AWS CodeCommit (p. 243).
1. On your local machine, download and install the AWS CLI. This is a prerequisite for interacting with
AWS CodeCommit from the command line. For more information, see Getting Set Up with the AWS
Command Line Interface.
Note
AWS CodeCommit works only with AWS CLI versions 1.7.38 and later. To determine which
version of the AWS CLI you have installed, run the aws --version command.
To upgrade an older version of the AWS CLI to the latest version, see Installing the AWS
Command Line Interface.
2. Run this command to verify the AWS CodeCommit commands for the AWS CLI are installed:
aws configure
When prompted, specify the AWS access key and AWS secret access key of the IAM user you will use
with AWS CodeCommit. Also, be sure to specify the region where the repository exists, such as us-
east-2. When prompted for the default output format, specify json. For example:
AWS Access Key ID [None]: Type your target AWS access key ID here, and then press Enter
AWS Secret Access Key [None]: Type your target AWS secret access key here, and then
press Enter
Default region name [None]: Type a supported region for AWS CodeCommit here, and then
press Enter
Default output format [None]: Type json here, and then press Enter
To connect to a repository or a resource in another region, you must re-configure the AWS CLI with
the default region name for that region. Supported default region names for AWS CodeCommit
include:
• us-east-2
• us-east-1
• eu-west-1
• us-west-2
• ap-northeast-1
• ap-southeast-1
• ap-southeast-2
• eu-central-1
• ap-northeast-2
• sa-east-1
• us-west-1
• eu-west-2
• ap-south-1
• ca-central-1
For more information about AWS CodeCommit and regions, see Regions and Git Connection
Endpoints (p. 272). For more information about IAM, access keys, and secret keys, see How Do I Get
Credentials? and Managing Access Keys for IAM Users.
To work with files, commits, and other information in AWS CodeCommit repositories, you must install
Git on your local machine. AWS CodeCommit supports Git versions 1.7.9 and later.
To work with files, commits, and other information in AWS CodeCommit repositories, you must install
Git on your local machine. AWS CodeCommit supports Git versions 1.7.9 and later.
To install Git, we recommend websites such as Git for Windows. If you use this link to install Git, you
can accept all of the installation default settings except for the following:
• When prompted during the Adjusting your PATH environment step, select the Use Git from the
Windows Command Prompt option.
• (Optional) If you intend to use HTTPS with the credential helper that is included in the AWS CLI
instead of configuring Git credentials for AWS CodeCommit, on the Configuring extra options page,
make sure the Enable Git Credential Manager option is cleared. The Git Credential Manager is only
compatible with AWS CodeCommit if IAM users configure Git credentials. For more information, see
For HTTPS Users Using Git Credentials (p. 5) and Git for Windows: I Installed Git for Windows, but I
Am Denied Access to My Repository (403) (p. 235).
Note
Git is an evolving, regularly updated platform. Occasionally, a feature change might affect the
way it works with AWS CodeCommit. If you encounter issues with a specific version of Git and
AWS CodeCommit, review the information in Troubleshooting (p. 228).
AWS CodeCommit supports both HTTPS and SSH authentication. To complete setup, you must configure
Git credentials for AWS CodeCommit (HTTPS, recommended for most users), an SSH key pair to use
when accessing AWS CodeCommit (SSH), or the credential helper included in the AWS CLI (HTTPS).
• For Git credentials on all supported operating systems, see Step 3: Create Git Credentials for HTTPS
Connections to AWS CodeCommit (p. 7).
• For SSH on Linux, macOS, or Unix, see SSH and Linux, macOS, or Unix: Set Up the Public and Private
Keys for Git and AWS CodeCommit (p. 26).
• For SSH on Windows, see SSH and Windows: Set Up the Public and Private Keys for Git and AWS
CodeCommit (p. 31).
• For the credential helper on Linux, macOS, or Unix, see Set Up the Credential Helper (Linux, macOS, or
Unix) (p. 36).
• For the credential helper on Windows, see Set Up the Credential Helper (Windows) (p. 41).
2. In the region selector, choose the region where you want to create the repository. For more
information, see Regions and Git Connection Endpoints (p. 272).
3. On the Repositories page, choose Create repository.
4. On the Create repository page, in Repository name, enter a name for the repository.
Note
This name must be unique in the region for your AWS account.
5. (Optional) In the Description box, enter a description for the repository. This can help you and other
users identify the purpose of the repository.
Note
The description field displays Markdown in the console and accepts all HTML characters
and valid Unicode characters. If you are an application developer who is using the
GetRepository or BatchGetRepositories APIs and you plan to display the repository
description field in a web browser, see the AWS CodeCommit API Reference.
6. Choose Create.
After it is created, the repository appears in the Repositories list. In the URL column, choose the copy
icon, and then choose the protocol (SSH or HTTPS) to be used to connect to AWS CodeCommit. Copy the
URL.
For example, if you named your repository MyClonedRepository and you are using Git credentials with
HTTPS in the US West (Oregon) region, the URL would look like the following:
https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyClonedRepository
You need this URL later in Step 2: Clone the Repository and Push to the AWS CodeCommit
Repository (p. 210).
1. From the terminal or command prompt on your local computer, run the git clone command with
the --mirror option to clone a bare copy of the remote repository into a new folder named
aws-codecommit-demo. This is a bare repo meant only for migration. It is not the local repo for
interacting with the migrated repository in AWS CodeCommit. You can create that later, after the
migration to AWS CodeCommit is complete.
The following example clones a sample application created for AWS demonstration purposes and
hosted on GitHub (https://github.com/awslabs/aws-demo-php-simple-app.git) to a
local repo in a directory named aws-codecommit-demo.
cd aws-codecommit-demo
3. Run the git push command, specifying the URL and name of the destination AWS CodeCommit
repository and the --all option. (This is the URL you copied in Step 1: Create an AWS CodeCommit
Repository (p. 208)).
For example, if you named your repository MyClonedRepository and you are set up to use HTTPS,
you would type the following command:
Note
The --all option only pushes all branches for the repository. It does not push other
references, such as tags. If you want to push tags, wait until the initial push is complete, and
then push again, this time using the --tags option:
For more information about git push and its options, see Git push on the Git website. For
information about pushing large repositories, especially when pushing all references at once
(for example, with the --mirror option), see Migrate a Repository in Increments (p. 220).
You can delete the aws-codecommit-demo folder and its contents after you have migrated the
repository to AWS CodeCommit. To create a local repo with all the correct references for working with
the repository in AWS CodeCommit, run the git clone command without the --mirror option:
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the Dashboard navigation area, choose Policies, and then choose Create Policy.
3. On the Create Policy page, next to Copy an AWS Managed Policy, choose Select.
4. On the Copy an AWS Managed Policy page, in Search Policies, enter AWSCodeCommitPowerUser.
Choose Select next to the policy name.
5. On the Review Policy page, in Policy Name, enter a new name for the policy (for example,
AWSCodeCommitPowerUser-MyDemoRepo).
In Policy Document, replace the "*" portion of the Resource line with the Amazon Resource Name
(ARN) of the AWS CodeCommit repository, as shown here:
"Resource": [
"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo"
]
Tip
To find the ARN for the AWS CodeCommit repository, go to the AWS CodeCommit console
and choose the repository name from the list. For more information, see View Repository
Details (p. 108).
If you want this policy to apply to more than one repository, add each repository as a resource by
specifying its ARN. Include a comma between each resource statement, as shown here:
"Resource": [
"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo",
"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyOtherDemoRepo"
]
6. Choose Validate Policy. After the policy is validated, choose Create Policy.
To manage access to your repository, create an IAM group for its users, add IAM users to that group, and
then attach the customer managed policy you created in the previous step. Attach any other policies
required for access, such as IAMUserSSHKeys or IAMSelfManageServiceSpecificCredentials.
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the Dashboard navigation area, choose Groups, and then choose Create New Group.
3. On the Set Group Name page, in Group Name, enter a name for the group (for example,
MyDemoRepoGroup), and then choose Next Step. Consider including the repository name as part of
the group name.
Note
This name must be unique across an AWS account.
4. Select the check box next to the customer managed policy you created in the previous section (for
example, AWSCodeCommitPowerUser-MyDemoRepo).
5. On the Review page, choose Create Group. IAM creates this group with the specified policies already
attached. The group appears in the list of groups associated with your AWS account.
6. Choose your group from the list.
7. On the group summary page, choose the Users tab, and then choose Add Users to Group. On the
list that shows all users associated with your AWS account, select the check boxes next to the users
to whom you want to allow access to the AWS CodeCommit repository, and then choose Add Users.
Tip
You can use the Search box to quickly find users by name.
8. When you have added your users, close the IAM console.
After you have created an IAM user to access AWS CodeCommit using the policy group and policies you
configured, send that user the information required to connect to the repository.
Topics
• Step 0: Setup Required for Access to AWS CodeCommit (p. 214)
• Step 1: Create an AWS CodeCommit Repository (p. 216)
• Step 2: Migrate Local Content to the AWS CodeCommit Repository (p. 217)
• Step 3: View Files in AWS CodeCommit (p. 218)
• Step 4: Share the AWS CodeCommit Repository (p. 218)
If you are already set up for AWS CodeCommit, you can skip ahead to Step 1: Create an AWS
CodeCommit Repository (p. 216).
After you have selected the policy you want to attach, choose Next: Review to review the list of
policies that will be attached to the IAM user. If the list is correct, choose Add permissions.
For more information about AWS CodeCommit managed policies and sharing access to repositories
with other groups and users, see Share a Repository (p. 81) and Authentication and Access Control
for AWS CodeCommit (p. 243).
1. On your local machine, download and install the AWS CLI. This is a prerequisite for interacting with
AWS CodeCommit from the command line. For more information, see Getting Set Up with the AWS
Command Line Interface.
Note
AWS CodeCommit works only with AWS CLI versions 1.7.38 and later. To determine which
version of the AWS CLI you have installed, run the aws --version command.
To upgrade an older version of the AWS CLI to the latest version, see Installing the AWS
Command Line Interface.
2. Run this command to verify the AWS CodeCommit commands for the AWS CLI are installed:
aws configure
When prompted, specify the AWS access key and AWS secret access key of the IAM user you will use
with AWS CodeCommit. Also, be sure to specify the region where the repository exists, such as us-
east-2. When prompted for the default output format, specify json. For example:
AWS Access Key ID [None]: Type your target AWS access key ID here, and then press Enter
AWS Secret Access Key [None]: Type your target AWS secret access key here, and then
press Enter
Default region name [None]: Type a supported region for AWS CodeCommit here, and then
press Enter
Default output format [None]: Type json here, and then press Enter
To connect to a repository or a resource in another region, you must re-configure the AWS CLI with
the default region name for that region. Supported default region names for AWS CodeCommit
include:
• us-east-2
• us-east-1
• eu-west-1
• us-west-2
• ap-northeast-1
• ap-southeast-1
• ap-southeast-2
• eu-central-1
• ap-northeast-2
• sa-east-1
• us-west-1
• eu-west-2
• ap-south-1
• ca-central-1
For more information about AWS CodeCommit and regions, see Regions and Git Connection
Endpoints (p. 272). For more information about IAM, access keys, and secret keys, see How Do I Get
Credentials? and Managing Access Keys for IAM Users.
To work with files, commits, and other information in AWS CodeCommit repositories, you must install
Git on your local machine. AWS CodeCommit supports Git versions 1.7.9 and later.
• For Windows:
To work with files, commits, and other information in AWS CodeCommit repositories, you must install
Git on your local machine. AWS CodeCommit supports Git versions 1.7.9 and later.
To install Git, we recommend websites such as Git for Windows. If you use this link to install Git, you
can accept all of the installation default settings except for the following:
• When prompted during the Adjusting your PATH environment step, select the Use Git from the
Windows Command Prompt option.
• (Optional) If you intend to use HTTPS with the credential helper that is included in the AWS CLI
instead of configuring Git credentials for AWS CodeCommit, on the Configuring extra options page,
make sure the Enable Git Credential Manager option is cleared. The Git Credential Manager is only
compatible with AWS CodeCommit if IAM users configure Git credentials. For more information, see
For HTTPS Users Using Git Credentials (p. 5) and Git for Windows: I Installed Git for Windows, but I
Am Denied Access to My Repository (403) (p. 235).
Note
Git is an evolving, regularly updated platform. Occasionally, a feature change might affect the
way it works with AWS CodeCommit. If you encounter issues with a specific version of Git and
AWS CodeCommit, review the information in Troubleshooting (p. 228).
AWS CodeCommit supports both HTTPS and SSH authentication. To complete setup, you must configure
Git credentials for AWS CodeCommit (HTTPS, recommended for most users), an SSH key pair (SSH) to
use when accessing AWS CodeCommit, or the credential helper included in the AWS CLI.
• For Git credentials on all supported operating systems, see Step 3: Create Git Credentials for HTTPS
Connections to AWS CodeCommit (p. 7).
• For SSH on Linux, macOS, or Unix, see SSH and Linux, macOS, or Unix: Set Up the Public and Private
Keys for Git and AWS CodeCommit (p. 26).
• For SSH on Windows, see SSH and Windows: Set Up the Public and Private Keys for Git and AWS
CodeCommit (p. 31).
• For the credential helper on Linux, macOS, or Unix, see Set Up the Credential Helper (Linux, macOS, or
Unix) (p. 36).
• For the credential helper on Windows, see Set Up the Credential Helper (Windows) (p. 41).
Note
The description field displays Markdown in the console and accepts all HTML characters
and valid Unicode characters. If you are an application developer who is using the
GetRepository or BatchGetRepositories APIs and you plan to display the repository
description field in a web browser, see the AWS CodeCommit API Reference.
6. Choose Create.
After it is created, the repository appears in the Repositories list. In the URL column, choose the copy
icon, and then choose the protocol (HTTPS or SSH) to be used to connect to AWS CodeCommit. Copy the
URL.
For example, if you named your repository MyFirstRepo and you are using HTTPS, the URL would look
like the following:
https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyFirstRepo
You need this URL later in Step 2: Migrate Local Content to the AWS CodeCommit Repository (p. 217).
1. From the terminal or command line on your local computer, change directories to the directory you
want to use as the source for your repository.
2. Run the git init command to initialize Git version control in the directory. This creates a .git
subdirectory in the root of the directory that enables version control tracking. The .git folder also
contains all of the required metadata for the repository.
git init
3. Add the files you want to add to version control. In this tutorial, you run the git add command
with the . specifier to add all of the files in this directory. For other options, consult your Git
documentation.
git add .
5. Run the git push command, specifying the URL and name of the destination AWS CodeCommit
repository and the --all option. (This is the URL you copied in Step 1: Create an AWS CodeCommit
Repository (p. 216).)
For example, if you named your repository MyFirstRepo and you are set up to use HTTPS, you
would type the following command:
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the Dashboard navigation area, choose Policies, and then choose Create Policy.
3. On the Create Policy page, next to Copy an AWS Managed Policy, choose Select.
4. On the Copy an AWS Managed Policy page, in Search Policies, enter AWSCodeCommitPowerUser.
Choose Select next to the policy name.
5. On the Review Policy page, in Policy Name, enter a new name for the policy (for example,
AWSCodeCommitPowerUser-MyDemoRepo).
In Policy Document, replace the "*" portion of the Resource line with the Amazon Resource Name
(ARN) of the AWS CodeCommit repository, as shown here:
"Resource": [
"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo"
]
Tip
To find the ARN for the AWS CodeCommit repository, go to the AWS CodeCommit console
and choose the repository name from the list. For more information, see View Repository
Details (p. 108).
If you want this policy to apply to more than one repository, add each repository as a resource by
specifying its ARN. Include a comma between each resource statement, as shown here:
"Resource": [
"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo",
"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyOtherDemoRepo"
]
6. Choose Validate Policy. After the policy is validated, choose Create Policy.
To manage access to your repository, create an IAM group for its users, add IAM users to that group, and
then attach the customer managed policy you created in the previous step. Attach any other policies
required for access, such as IAMSelfManageServiceSpecificCredentials or IAMUserSSHKeys.
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the Dashboard navigation area, choose Groups, and then choose Create New Group.
3. On the Set Group Name page, in Group Name, enter a name for the group (for example,
MyDemoRepoGroup), and then choose Next Step. Consider including the repository name as part of
the group name.
Note
This name must be unique across an AWS account.
4. Select the check box next to the customer managed policy you created in the previous section (for
example, AWSCodeCommitPowerUser-MyDemoRepo).
5. On the Review page, choose Create Group. IAM creates this group with the specified policies already
attached. The group appears in the list of groups associated with your AWS account.
6. Choose your group from the list.
7. On the group summary page, choose the Users tab, and then choose Add Users to Group. On the
list that shows all users associated with your AWS account, select the check boxes next to the users
to whom you want to allow access to the AWS CodeCommit repository, and then choose Add Users.
Tip
You can use the Search box to quickly find users by name.
8. When you have added your users, close the IAM console.
After you have created an IAM user to be used to access AWS CodeCommit using the policy group and
policies you configured, send that user the information required to connect to the repository.
2. In the region selector, choose the region where the repository was created. Repositories are specific
to an AWS region. For more information, see Regions and Git Connection Endpoints (p. 272).
3. On the Repositories page, find the name of the repository you want to share.
4. In Clone URL, choose the protocol (HTTPS or SSH) that you want your users to use. This copies the
clone URL for the connection protocol.
5. Send your users the clone URL along with any other instructions, such as installing the AWS CLI,
configuring a profile, or installing Git. Make sure to include the configuration information for the
connection protocol (for example, for HTTPS, configuring the credential helper for Git).
The procedures in this topic show you how to create and run a script that migrates your repository in
increments and repushes only those increments that did not succeed until the migration is complete.
These instructions are written with the assumption that you have already completed the steps in Setting
Up (p. 4) and Create a Repository (p. 76).
Topics
• Step 0: Determine Whether to Migrate Incrementally (p. 220)
• Step 1: Install Prerequisites and Add the AWS CodeCommit Repository as a Remote (p. 221)
• Step 2: Create the Script to Use for Migrating Incrementally (p. 222)
• Step 3: Run the Script and Migrate Incrementally to AWS CodeCommit (p. 222)
• Appendix: Sample Script incremental-repo-migration.py (p. 223)
You might want to configure incremental pushes if one or more of the following conditions is true:
• The repository you want to migrate has more than five years of history.
• Your internet connection is subject to intermittent outages, dropped packets, slow response, or other
interruptions in service.
• The overall size of the repository is larger than 2 GB and you intend to migrate the entire repository.
• The repository contains large artifacts or binaries that do not compress well, such as large image files
with more than five tracked versions.
• You have previously attempted a migration to AWS CodeCommit and received an "Internal Service
Error" message.
Even if none of the above conditions are true, you can still choose to push incrementally.
1. On your local computer, install Python 2.6 or later. For more information and the latest versions, see
the Python website.
2. On the same computer, install GitPython, which is a Python library used to interact with Git
repositories. For more information, see the GitPython documentation.
3. Use the git clone --mirror command to clone the repository you want to migrate to your local
computer. From the terminal (Linux, macOS, or Unix) or the command prompt (Windows), use the
git clone --mirror command to create a local repo for the repository, including the directory where
you want to create the local repo. For example, to clone a Git repository named MyMigrationRepo
with a URL of https://example.com/my-repo/ to a directory named my-repo:
You should see output similar to the following, which indicates the repository has been cloned into a
bare local repo named my-repo:
4. Change directories to the local repo for the repository you just cloned (for example, my-repo). From
that directory, use the git remote add DefaultRemoteName RemoteRepositoryURL command to
add the AWS CodeCommit repository as a remote repository for the local repo.
Note
When pushing large repositories, consider using SSH instead of HTTPS. When you push
a large change, a large number of changes, or a large repository, long-running HTTPS
connections are often terminated prematurely due to networking issues or firewall settings.
For more information about setting up AWS CodeCommit for SSH, see For SSH Connections
on Linux, macOS, or Unix (p. 25) or For SSH Connections on Windows (p. 29).
For example, use the following command to add the SSH endpoint for an AWS CodeCommit
repository named MyDestinationRepo as a remote repository for the remote named codecommit:
Tip
Because this is a clone, the default remote name (origin) is already in use. You must use
another remote name. Although the example uses codecommit, you can use any name you
want. Use the git remote show command to review the list of remotes set for your local
repo.
5. Use the git remote -v command to display the fetch and push settings for your local repo and
confirm they are set correctly. For example:
codecommit ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDestinationRepo
(fetch)
codecommit ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDestinationRepo
(push)
Tip
If you still see fetch and push entries for a different remote repository (for example, entries
for origin), use the git remote set-url --delete command to remove them.
1. Open a text editor and paste the contents of the sample script (p. 223) into an empty document.
2. Save the document in a documents directory (not the working directory of your local repo)
and name it incremental-repo-migration.py. Make sure the directory you choose is one
configured in your local environment or path variables, so you can run the Python script from a
command line or terminal.
1. From the terminal or command prompt, change directories to the local repo you want to migrate.
2. From that directory, type the following command:
python incremental-repo-migration.py
3. The script runs and shows progress at the terminal or command prompt. Some large repositories
are slow to show progress. The script stops if a single push fails three times. You can then rerun the
script, and it starts from the batch that failed. You can rerun the script until all pushes succeed and
the migration is complete.
Tip
You can run incremental-repo-migration.py from any directory as long as you use the -
l and -r options to specify the local and remote settings to use. For example, to use the script
from any directory to migrate a local repo located at /tmp/my-repo to a remote nicknamed
codecommit:
You might also want to use the -b option to change the default batch size used when pushing
incrementally. For example, if you are regularly pushing a repository with very large binary files
that change often and are working from a location that has restricted network bandwidth, you
might want to use the -b option to change the batch size to 500 instead of 1,000. For example:
This pushes the local repo incrementally in batches of 500 commits. If you decide to change the
batch size again when you migrate the repository (for example, if you decide to decrease the
batch size after an unsuccessful attempt), remember to use the -c option to remove the batch
tags before resetting the batch size with -b:
python incremental-repo-migration.py -c
python incremental-repo-migration.py -b 250
Important
Do not use the -c option if you want to rerun the script after a failure. The -c option removes
the tags used to batch the commits. Use the -c option only if you want to change the batch size
and start again, or if you decide you no longer want to use the script.
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under
the Amazon Software License (the "License").
# You may not use this file except in compliance with the License. A copy of the License is
located at
# http://aws.amazon.com/asl/
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, express or implied. See the License for
# the specific language governing permissions and limitations under the License.
#!/usr/bin/env python
import os
import sys
from optparse import OptionParser
from git import Repo, TagReference, RemoteProgress, GitCommandError
class PushProgressPrinter(RemoteProgress):
def update(self, op_code, cur_count, max_count=None, message=''):
op_id = op_code & self.OP_MASK
stage_id = op_code & self.STAGE_MASK
if op_id == self.WRITING and stage_id == self.BEGIN:
print("\tObjects: %d" % max_count)
class RepositoryMigration:
MAX_COMMITS_TOLERANCE_PERCENT = 0.05
PUSH_RETRY_LIMIT = 3
MIGRATION_TAG_PREFIX = "codecommit_migration_"
try:
self.remote_repo = self.local_repo.remote(remote_name)
self.get_remote_migration_tags()
except (ValueError, GitCommandError):
print("Could not contact the remote repository. The most common reasons for
this error are that the name of the remote repository is incorrect, or that you do not
have permissions to interact with that remote repository.")
sys.exit(1)
if clean:
self.clean_up(clean_up_remote=True)
return
self.clean_up()
print("Analyzing repository")
head_commit = self.local_repo.head.commit
sys.setrecursionlimit(max(sys.getrecursionlimit(), head_commit.count()))
self.get_remote_migration_tags()
self.clean_up(clean_up_remote=True)
pending_ancestor_pushes = []
commit_count = 1
if len(commit.parents) > 1:
# This is a merge commit
# Ensure that all parents are pushed first
for parent_commit in commit.parents:
pending_ancestor_pushes.extend(self.migrate_commit(parent_commit))
elif len(commit.parents) == 1:
# Split linear history into individual pushes
next_ancestor, commits_to_next_ancestor =
self.find_next_ancestor_for_push(commit.parents[0])
commit_count += commits_to_next_ancestor
pending_ancestor_pushes.extend(self.migrate_commit(next_ancestor))
self.walked_commits.add(commit)
# Traverse linear history until we reach our commit limit, a merge commit, or an
initial commit
while len(commit.parents) == 1 and commit_count < self.max_commits_per_push and
commit not in self.walked_commits:
commit_count += 1
self.walked_commits.add(commit)
commit = commit.parents[0]
def push_migration_tags(self):
print("Will attempt to push %d tags" % len(self.migration_tags))
self.migration_tags.sort(key=lambda tag:
int(tag.name.replace(self.MIGRATION_TAG_PREFIX, "")))
for tag in self.migration_tags:
print("Pushing tag %s (out of %d tags), commit %s" % (tag.name,
self.next_tag_number, str(tag.commit)))
self.do_push_with_retries(ref=tag.name)
try:
if push_tags:
infos = self.remote_repo.push(tags=True, progress=progress_printer)
elif ref is not None:
infos = self.remote_repo.push(refspec=ref, progress=progress_printer)
else:
infos = self.remote_repo.push(progress=progress_printer)
success = True
if len(infos) == 0:
success = False
else:
for info in infos:
if info.flags & info.UP_TO_DATE or info.flags & info.NEW_TAG or
info.flags & info.NEW_HEAD:
continue
success = False
print(info.summary)
if success:
return
except GitCommandError as err:
print(err)
if push_tags:
print("Pushing all tags failed after %d attempts" % (self.PUSH_RETRY_LIMIT))
elif ref is not None:
print("Pushing %s failed after %d attempts" % (ref, self.PUSH_RETRY_LIMIT))
print("For more information about the cause of this error, run the following
command from the local repo: 'git push %s %s'" % (self.remote_name, ref))
else:
print("Pushing all branches failed after %d attempts" %
(self.PUSH_RETRY_LIMIT))
sys.exit(1)
def get_remote_migration_tags(self):
remote_tags_output = self.local_repo.git.ls_remote(self.remote_name,
tags=True).split('\n')
self.remote_migration_tags = dict((tag.split()[1].replace("refs/tags/",""),
tag.split()[0]) for tag in remote_tags_output if self.MIGRATION_TAG_PREFIX in tag)
parser = OptionParser()
parser.add_option("-l", "--local",
action="store", dest="localrepo", default=os.getcwd(),
help="The path to the local repo. If this option is not specified, the
script will attempt to use current directory by default. If it is not a local git repo,
the script will fail.")
parser.add_option("-r", "--remote",
action="store", dest="remoterepo", default="codecommit",
help="The name of the remote repository to be used as the push or
migration destination. The remote must already be set in the local repo ('git remote
add ...'). If this option is not specified, the script will use 'codecommit' by default.")
parser.add_option("-b", "--batch",
action="store", dest="batchsize", default="1000",
help="Specifies the commit batch size for pushes. If not explicitly set,
the default is 1,000 commits.")
parser.add_option("-c", "--clean",
action="store_true", dest="clean", default=False,
help="Remove the temporary tags created by migration from both the local
repo and the remote repository. This option will not do any migration work, just cleanup.
Cleanup is done automatically at the end of a successful migration, but not after a
failure so that when you re-run the script, the tags from the prior run can be used to
identify commit batches that were not pushed successfully.")
migration = RepositoryMigration()
migration.migrate_repository_in_parts(options.localrepo, options.remoterepo,
int(options.batchsize), options.clean)
Topics
• Troubleshooting Git Credentials and HTTPS Connections to AWS CodeCommit (p. 228)
• Troubleshooting SSH Connections to AWS CodeCommit (p. 229)
• Troubleshooting the Credential Helper and HTTPS Connections to AWS CodeCommit (p. 233)
• Troubleshooting Git Clients and AWS CodeCommit (p. 237)
• Troubleshooting Access Errors and AWS CodeCommit (p. 238)
• Troubleshooting Configuration Errors and AWS CodeCommit (p. 240)
• Troubleshooting Console Errors and AWS CodeCommit (p. 240)
• Troubleshooting Triggers and AWS CodeCommit (p. 241)
• Turn on Debugging (p. 241)
Topics
• Git Credentials for AWS CodeCommit: I Keep Seeing a Prompt for Credentials When Connecting to
My AWS CodeCommit Repository at the Terminal or Command Line (p. 228)
• Git Credentials for AWS CodeCommit: I Set Up Git Credentials, But My System Is Not Using Them As I
Expected (p. 229)
Possible fixes: The most common causes for this error are that your local computer is running an
operating system that does not support credential management, or it does not have a credential
management utility installed, or the Git credentials for your IAM user have not been saved to one of
these credential management systems. Depending on your operating system and local environment,
you might need to install a credential manager, configure the credential manager that is included in
your operating system, or customize your local environment to use credential storage. For example, if
your computer is running macOS, you can use the Keychain Access utility to store your credentials. If
your computer is running Windows, you can use the Git Credential Manager that is installed with Git for
Windows. For more information, see For HTTPS Users Using Git Credentials (p. 5) and Credential Storage
in the Git documentation.
Possible fixes: The most common cause for this error is that you previously set up your computer to
use the credential helper that is included with the AWS CLI. Check your .gitconfig file for configuration
sections similar to the following, and remove them:
[credential "https://git-codecommit.*.amazonaws.com"]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
Save the file, and then open a new command line or terminal session before you attempt to connect
again.
You may also have multiple credential helpers or managers set up on your computer, and your system
might be defaulting to another configuration. To reset which credential helper is used as the default, you
can use the --system option instead of --global or --local when running the git config command.
For more information, see For HTTPS Users Using Git Credentials (p. 5) and Credential Storage in the Git
documentation.
Topics
• Access Error: Public Key Is Uploaded Successfully to IAM but Connection Fails on Linux, macOS, or
Unix Systems (p. 229)
• Access Error: Public Key Is Uploaded Successfully to IAM and SSH Tested Successfully but Connection
Fails on Windows Systems (p. 230)
• Authentication Challenge: Authenticity of Host Can't Be Established When Connecting to an AWS
CodeCommit Repository (p. 231)
• IAM Error: 'Invalid format' when attempting to add a public key to IAM (p. 233)
• Git on Windows: Bash Emulator or Command Line Freezes When Attempting to Connect Using
SSH (p. 233)
The SSH Key ID can be found in the IAM console in the profile for your IAM user:
If you see a success message after confirming the connection, your SSH Key ID is valid. Edit your config
file to associate your connection attempts with your public key in IAM. If you do not want to edit your
config file for some reason, you can preface all connection attempts to your repository with your SSH
Key ID. For example, if you wanted to clone a repository named MyDemoRepo without modifying your
config file to associate your connection attempts, you would type the following command:
For more information, see For SSH Connections on Linux, macOS, or Unix (p. 25).
Possible fixes: The most common reason for this error is that you have a Windows system environment
variable set that directs Windows to use another program when you attempt to use SSH. For example,
you might have set a GIT_SSH variable to point to one of the PuTTY set of tools (plink.exe). This might
be a legacy configuration, or it might be necessary for one or more other programs installed on your
computer. If you are sure that this environment variable is not needed, you can remove it by opening
your system properties and deleting the environment variable.
To work around this issue, open a Bash emulator and then try your SSH connection again, but include
GIT_SSH_COMMAND="SSH" as a prefix. For example, to clone a repository using SSH:
A similar problem might occur if your version of Windows requires that you include the SSH Key ID
as part of the connection string when connecting using SSH at the Windows command line. Try your
connection again, this time including the SSH Key ID copied from IAM as part of the command. For
example:
Possible fixes: Your credentials might not be set up correctly. Follow the instructions in For SSH
Connections on Linux, macOS, or Unix (p. 25) or For SSH Connections on Windows (p. 29).
If you have followed those steps and the problem persists, someone might be attempting a man-in-the-
middle attack. When you see the following message, type no, and press Enter.
Make sure the fingerprint and public key for AWS CodeCommit connections match those documented in
the SSH setup topics before you continue with the connection.
Possible fixes: IAM accepts public keys in the OpenSSH format only. If you provide your public key
in another format, or if the key does not contain the required number of bits, you will see this error.
This problem most commonly occurs when the public/private key pairs are generated on Windows
computers. To generate a key pair and copy the OpenSSH format required by IAM, see the section called
“SSH and Windows: Set Up the Public and Private Keys for Git and AWS CodeCommit” (p. 31).
Possible fixes: The most common cause for this error is that your Git environment is configured to use
something other than OpenSSH for authentication (probably PuTTY). This is known to cause problems
with the caching of keys in some configurations. To fix this problem, try one of the following:
• Open a Bash emulator and add the GIT_SSH_COMMAND="ssh" parameter before the Git command.
For example, if you are attempting to push to a repository, instead of typing git push, type:
• If you have PuTTY installed, open PuTTY, and in Host Name (or IP address), type the AWS
CodeCommit endpoint you want to reach (for example, git-codecommit.us-east-2.amazonaws.com).
Choose Open. When prompted by the PuTTY Security Alert, choose Yes to permanently cache the key.
• Rename or delete the GIT_SSH environment variable if you are no longer using it. Then open a new
command prompt or Bash emulator session, and try your command again.
For other solutions, see Git clone/pull continually freezing at Store key in cache on Stack Overflow.
Topics
• Git for macOS: I Configured the Credential Helper Successfully, but Now I Am Denied Access to My
Repository (403) (p. 234)
• Git for Windows: I Installed Git for Windows, but I Am Denied Access to My Repository
(403) (p. 235)
• The AWS CLI is configured for a different AWS region than the one where the repository exists.
• The Keychain Access utility has saved credentials which have since expired.
Possible fixes: To verify whether the AWS CLI is configured for the correct region, run the aws configure
command, and review the displayed information. If the AWS CodeCommit repository is in a region
different from the one shown for the AWS CLI, you must run the aws configure command and change
the values to ones appropriate for that region. For more information, see Step 1: Initial Configuration for
AWS CodeCommit (p. 34).
The default version of Git released on OS X and macOS uses the Keychain Access utility to save
generated credentials. For security reasons, the password generated for access to your AWS CodeCommit
repository is temporary, so the credentials stored in the keychain stop working after about 15 minutes. If
you are only accessing Git with AWS CodeCommit, try the following:
1. In Terminal, run the git config command to find the Git configuration file (gitconfig) where the
Keychain Access utility is defined. Depending on your local system and preferences, you might have
more than one gitconfig file.
In the output from this command, find a line that contains the following option:
helper = osxkeychain
The file listed at the beginning of this line is the Git configuration file you must edit.
2. To edit the Git configuration file, use a plain-text editor or run the following command:
$ nano /usr/local/git/etc/gitconfig
# helper = osxkeychain
Alternatively, if you want to continue to use the Keychain Access utility to cache credentials for
other Git repositories, modify the header instead of commenting out the line. For example, to allow
cached credentials for GitHub, you could modify the header as follows:
[credential "https://github.com"]
helper = osxkeychain
If you are accessing other repositories with Git, you can configure the Keychain Access utility so that it
does not supply credentials for your AWS CodeCommit repositories. To configure the Keychain Access
utility:
API Version 2015-04-13
234
AWS CodeCommit User Guide
Git for Windows: I Installed Git for Windows,
but I Am Denied Access to My Repository (403)
1. Open the Keychain Access utility. (You can use Finder to locate it.)
2. Search for git-codecommit.us-east-2.amazonaws.com. Highlight the row, open the context
(right-click) menu, and then choose Get Info.
3. Choose the Access Control tab.
4. In Confirm before allowing access, choose git-credential-osxkeychain, and then choose the
minus sign to remove it from the list.
Note
After removing git-credential-osxkeychain from the list, you see a dialog box
whenever you run a Git command. Choose Deny to continue. If you find the pop-ups too
disruptive, here are some alternatives:
• Connect to AWS CodeCommit using SSH instead of HTTPS. For more information, see For
SSH Connections on Linux, macOS, or Unix (p. 25).
• In the Keychain Access utility, on the Access Control tab for git-codecommit.us-
east-2.amazonaws.com, choose the Allow all applications to access this item (access
to this item is not restricted) option. This prevents the pop-ups, but the credentials
eventually expire (on average, this takes about 15 minutes) and you then see a 403 error
message. When this happens, you must delete the keychain item to restore functionality.
• Install a version of Git that does not use the keychain by default.
• Consider a scripting solution for deleting the keychain item. To view a community-
generated sample of a scripted solution, see Mac OS X Script to Periodically Delete
Cached Credentials in the OS X Certificate Store (p. 74) in Product and Service
Integrations (p. 68).
If you want to stop Git from using the Keychain Access utility entirely, you can configure Git to stop using
'osxkeychain' as the credential helper. For example, if you open a terminal and run the command git
config --system credential.helper, and it returns osxkeychain, you will know that Git is set to
use the Keychain Access utility. You can change this by running the following command:
Be aware that by running this command with the --system option changes the Git behavior system-
wide for all users, and this might have unintended consequences for other users, or for other repositories
if you're using other repository services in addition to AWS CodeCommit. Also be aware that this
approach might require the use of sudo, and that your account might not have sufficient system
permissions to apply this change. Make sure to verify that the command applied successfully by re-
running the git config --system credential.helper command. For more information, see
Customizing Git - Git Configuration and this article on Stack Overflow.
• The AWS CLI is configured for an AWS Region different from the one where the repository exists.
• By default, Git for Windows installs a Git Credential Manager utility that is not compatible with AWS
CodeCommit connections that use the AWS credential helper. When installed, it causes connections
to repository to fail even thought the credential helper has been installed with the AWS CLI and
configured for connections to AWS CodeCommit.
• Some versions of Git for Windows might not be in full compliance with RFC 2617 and RFC 4559, which
could potentially cause issues with both Git credentials and the credential helper included with the
AWS CLI. For more information, see Version 2.11.0(3) does not ask for username/password.
Possible fixes:
• If you are attempting to use the credential helper included with the AWS CLI, consider connecting with
Git credentials over HTTPS instead of using the credential helper. Git credentials configured for your
IAM user are compatible with the Git Credential Manager for Windows, unlike the credential helper for
AWS CodeCommit. For more information, see For HTTPS Users Using Git Credentials (p. 5).
If you want to use the credential helper, to verify whether the AWS CLI is configured for the
correct region, run the aws configure command, and review the displayed information. If the AWS
CodeCommit repository is in a region different from the one shown for the AWS CLI, you must run
the aws configure command and change the values to ones appropriate for that region. For more
information, see Step 1: Initial Configuration for AWS CodeCommit (p. 38).
• If possible, uninstall and reinstall Git for Windows. When you install Git for Windows, clear the
check box for the option to install the Git Credential Manager utility. This credential manager is
not compatible with the credential helper for AWS CodeCommit. If you installed the Git Credential
Manager or another credential management utility and you do not want to uninstall it, you can modify
your .gitconfig file and add specific credential management for AWS CodeCommit:
1. Open Control Panel, choose Credential Manager, and remove any stored credentials for AWS
CodeCommit.
2. Open your .gitconfig file in any plain-text editor, such as Notepad.
Note
If you work with multiple Git profiles, you might have both local and global .gitconfig
files. Be sure to edit the appropriate file.
3. Add the following section to your .gitconfig file:
[credential "https://git-codecommit.*.amazonaws.com"]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
4. Save the file, and then open a new command line session before you attempt to connect again.
You can also use this approach if you want to use the credential helper for AWS CodeCommit when
you connect to AWS CodeCommit repositories and another credential management system when you
connect to other hosted repositories, such as GitHub repositories.
To reset which credential helper is used as the default, you can use the --system option instead of --
global or --local when you run the git config command.
• If you are using Git credentials on a Windows computer, you can try to work around any RFC
noncompliance issues by including your Git credential user name as part of the connection string. For
example, to work around the issue and clone a repository named MyDemoRepo in the US East (Ohio)
region:
Note
This approach does not work if you have an @ character in your Git credentials user name. You
must URL-encode (also known as URL escaping or percent-encoding) the character before it
will work.
Topics
• Git Error: error: RPC failed; result=56, HTTP code = 200 fatal: The remote end hung up unexpectedly
(p. 237)
• Git Error: Too many reference update commands (p. 237)
• Git Error: push via HTTPS is broken in some versions of Git (p. 237)
• Git Error: 'gnutls_handshake() failed' (p. 237)
• Git Error: Git cannot find the AWS CodeCommit repository or does not have permission to access the
repository (p. 238)
• Git on Windows: No Supported Authentication Methods Available (publickey) (p. 238)
Possible fixes: Push with SSH instead, or when migrating a large repository, follow the steps in Migrate
a Repository in Increments (p. 220). Also, make sure you are not exceeding the size limits for individual
files. For more information, see Limits (p. 277).
Possible fixes: Try pushing branches and tags individually with git push --all and git push
--tags. If you have too many tags, split the tags into multiple pushes. For more information, see
Limits (p. 277).
Possible fixes: Check your version of Git for known issues or use an earlier or later version. For more
information about mysysgit, see Push to HTTPS Is Broken in the GitHub forums. For more information
about Git for Windows version issues, see Version 2.11.0(3) does not ask for username/password.
Possible fixes: Compile Git against OpenSSL. For one approach, see "Error: gnutls_handshake() failed"
When Connecting to HTTPS Servers in the Ask Ubuntu forums.
Alternatively, use SSH instead of HTTPS to communicate with AWS CodeCommit repositories.
Possible fixes: Make sure that you have provided the correct name and connection string for
the repository, and that there are no trailing slashes. For more information, see Connect to a
Repository (p. 78).
Possible fixes: The most common cause for this error is that a GIT_SSH environment variable exists
on your computer and is configured to support another connection utility, such as PuTTY. To fix this
problem, try one of the following:
• Open a Bash emulator and add the GIT_SSH_COMMAND="ssh" parameter before the Git command.
For example, if you are attempting to clone a repository, instead of typing git clone ssh://git-
codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo my-demo-repo, type:
• Rename or delete the GIT_SSH environment variable if you are no longer using it. Then open a new
command prompt or Bash emulator session, and try your command again.
For more information about troubleshooting Git issues on Windows when using SSH, see
Troubleshooting SSH Connections (p. 229).
Topics
• Access Error: Prompted for AWS User Name When Connecting to an AWS CodeCommit
Repository (p. 239)
• Access Error: Prompted for User Name and Password When Connecting to an AWS CodeCommit
Repository from Windows (p. 239)
• Access Error: Public Key Denied When Connecting to an AWS CodeCommit Repository (p. 239)
Possible fixes: Configure your AWS profile or make sure the profile you are using is the one you
configured for working with AWS CodeCommit. For more information about setting up, see Setting Up
(p. 4). For more information about IAM, access keys, and secret keys, see Managing Access Keys for IAM
Users and How Do I Get Credentials?.
Possible fixes: This might be the built-in credential management system for Windows. Depending on
your configuration, do one of the following:
• If you are using HTTPS with Git credentials, your Git credentials are not yet stored in the system.
Provide the Git credentials and continue. You should not be prompted again. For more information,
see For HTTPS Users Using Git Credentials (p. 5).
• If you are using HTTPS with the credential helper for AWS CodeCommit, it is not compatible with the
Windows credential management system. Choose Cancel.
This might also be an indication that you installed the Git Credential Manager as part of installing
Git for Windows. The Git Credential Manager is not compatible with AWS CodeCommit. Consider
uninstalling it.
For more information, see For HTTPS Connections on Windows with the AWS CLI Credential
Helper (p. 38) and Git for Windows: I Installed Git for Windows, but I Am Denied Access to My
Repository (403) (p. 235).
Possible fixes: The most common reason for this error is that you have not completed set up for SSH
connections. Configure a public and private SSH key pair, and then associate the public key with your
IAM user. For more information about configuring SSH, see For SSH Connections on Linux, macOS, or
Unix (p. 25) and For SSH Connections on Windows (p. 29).
Topics
• Configuration Error: Cannot Configure AWS CLI Credentials on macOS (p. 240)
Possible fixes: The most common cause for this error is that a credentials file already exists. Browse to
~/.aws and look for a file named credentials. Rename or delete that file, and then run aws configure
again.
Topics
• Access Error: Encryption Key Access Denied for an AWS CodeCommit Repository from the Console or
the AWS CLI (p. 240)
• Console Error: Cannot Browse the Code in an AWS CodeCommit Repository from the
Console (p. 241)
Possible fixes: The most common cause for this error is that your AWS account is not subscribed to
AWS Key Management Service, which is required for AWS CodeCommit. Open the IAM console, choose
Encryption Keys, and then choose Get Started Now. If you see a message that you are not currently
subscribed to the AWS Key Management Service service, follow the instructions on that page to
subscribe. For more information about AWS CodeCommit and AWS Key Management Service, see AWS
KMS and Encryption (p. 282).
Possible fixes: The most common cause for this error is that an IAM policy applied to your AWS account
denies one or more of the permissions required for browsing code from the AWS CodeCommit console.
For more information about AWS CodeCommit access permissions and browsing, see Authentication and
Access Control for AWS CodeCommit (p. 243).
Topics
• Trigger Error: A Repository Trigger Does Not Run When Expected (p. 241)
Possible fixes: If the target of the trigger is a AWS Lambda function, make sure you have configured the
function's resource policy for access by AWS CodeCommit. For more information, see Example 2: Create a
Policy for AWS Lambda Integration (p. 261).
Alternatively, edit the trigger and make sure the events for which you want to trigger actions have been
selected and that the branches for the trigger include the branch where you want to see responses to
actions. Try changing the settings for the trigger to All repository events and All branches and then
testing the trigger. For more information, see Edit Triggers for a Repository (p. 104).
Turn on Debugging
Problem: I want to turn on debugging to get more information about my repository and how Git is
executing commands.
1. At the terminal or command prompt, run the following commands on your local machine before
running Git commands:
export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1
On Windows:
set GIT_TRACE_PACKET=1
set GIT_TRACE=1
set GIT_CURL_VERBOSE=1
Note
Setting GIT_CURL_VERBOSE is useful for HTTPS connections only. SSH does not use the
libcurl library.
2. To get more information about your Git repository, create a shell script similar to the following, and
then run the script:
#!/bin/sh
echo "Size: `git count-objects -v | grep size-pack | awk '{print $2}'` KiB"
echo "Branches: $branch_count"
echo "Tags: `git show-ref --tags | wc -l`"
echo "Commits: `git rev-list --all | wc -l`"
echo "Objects: $object_count"
echo "Delta objects: $delta_count"
echo "Largest blob: $largest_object"
echo "Largest commit/tag/tree: $largest_commit"
echo "Longest delta chain: $longest_delta_chain"
3. If these steps do not provide enough information for you to resolve the issue on your own, ask for
help on the AWS CodeCommit forum. Be sure to include relevant output from these steps in your
post.
Authentication
Because AWS CodeCommit repositories are Git-based and support the basic functionality of Git,
including Git credentials, we recommend that you use an IAM user when working with AWS CodeCommit.
You can access AWS CodeCommit with other identity types, but the other identity types are subject to
limitations, as described below.
Identity types:
• IAM user – An IAM user is simply an identity within your AWS account that has specific custom
permissions. For example, an IAM user can have permissions to create and manage Git credentials for
accessing AWS CodeCommit repositories. This is the recommended user type for working with AWS
CodeCommit. You can use an IAM user name and password to sign in to secure AWS webpages like the
AWS Management Console, AWS Discussion Forums, or the AWS Support Center.
You can generate Git credentials or associate SSH public keys with your IAM user. These are the easiest
ways to set up Git to work with your AWS CodeCommit repositories. With Git credentials, you generate
a static user name and password in IAM. You then use these credentials for HTTPS connections
with Git and any third-party tool that supports Git user name and password authentication. With
SSH connections, you create public and private key files on your local machine that Git and AWS
CodeCommit use for SSH authentication. You associate the public key with your IAM user, and you
store the private key on your local machine.
In addition, you can generate access keys for each user. Use access keys when you access AWS services
programmatically, either through one of the AWS SDKs or by using the AWS Command Line Interface
(AWS CLI). The SDK and CLI tools use the access keys to cryptographically sign your requests. If
you don’t use the AWS tools, you must sign the requests yourself. AWS CodeCommit supports
Signature Version 4, a protocol for authenticating inbound API requests. For more information about
authenticating requests, see Signature Version 4 Signing Process in the AWS General Reference.
• AWS account root user – When you sign up for AWS, you provide an email address and password that
is associated with your AWS account. These are your root credentials, and they provide complete access
to all of your AWS resources. Certain AWS CodeCommit features are not available for root account
users. In addition, the only way to use Git with your root account is to configure the AWS credential
helper, which is included with the AWS CLI. You cannot use Git credentials or SSH public-private key
pairs with your root account user. For these reasons, we do not recommend using your root account
user when interacting with AWS CodeCommit.
Important
For security reasons, we recommend that you use the root credentials only to create an
administrator user, which is an IAM user with full permissions to your AWS account. Then, you
can use this administrator user to create other IAM users and roles with limited permissions.
For more information, see IAM Best Practices and Creating an Admin User and Group in the
IAM User Guide.
• IAM role – Like an IAM user, an IAM role is an IAM identity that you can create in your account to grant
specific permissions. It is similar to an IAM user, but it is not associated with a specific person. Unlike
an IAM user identity, you cannot use Git credentials or SSH keys with this identity type. However, an
IAM role enables you to obtain temporary access keys that you can use to access AWS services and
resources. IAM roles with temporary credentials are useful in the following situations:
• Federated user access – Instead of creating an IAM user, you can use preexisting user identities from
AWS Directory Service, your enterprise user directory, or a web identity provider. These are known as
federated users. AWS assigns a role to a federated user when access is requested through an identity
provider. For more information about federated users, see Federated Users and Roles in the IAM User
Guide.
Note
You cannot use Git credentials or SSH public-private key pairs with federated users. In
addition, user preferences are not available for federated users.
• Cross-account access – You can use an IAM role in your account to grant another AWS account
permissions to access your account’s resources. For an example, see Tutorial: Delegate Access Across
AWS Accounts Using IAM Roles in the IAM User Guide.
• AWS service access – You can use an IAM role in your account to grant an AWS service permissions
to access your account’s resources. For example, you can create a role that allows AWS Lambda to
access an AWS CodeCommit repository on your behalf. For more information, see Creating a Role to
Delegate Permissions to an AWS Service in the IAM User Guide.
• Applications running on Amazon EC2 – Instead of storing access keys within an EC2 instance
for use by applications running on the instance and for making AWS API requests, you can use an
IAM role to manage temporary credentials for these applications. To assign an AWS role to an EC2
instance and make it available to all of its applications, you can create an instance profile that is
attached to the instance. An instance profile contains the role and enables programs running on the
EC2 instance to get temporary credentials. For more information, see Using Roles for Applications
on Amazon EC2 in the IAM User Guide.
Access Control
You can have valid credentials to authenticate your requests, but unless you have permissions you
cannot create or access AWS CodeCommit resources. For example, you must have permissions to view
repositories, push code, create and manage Git credentials, and so on.
The following sections describe how to manage permissions for AWS CodeCommit. We recommend that
you read the overview first.
• Overview of Managing Access Permissions to Your AWS CodeCommit Resources (p. 244)
• Using Identity-Based Policies (IAM Policies) for AWS CodeCommit (p. 249)
• AWS CodeCommit Permissions Reference (p. 262)
Note
An account administrator (or administrator user) is a user with administrator privileges. For more
information, see IAM Best Practices in the IAM User Guide.
When granting permissions, you decide who gets the permissions, the resources they get permissions for,
and the specific actions that you want to allow on those resources.
Topics
• AWS CodeCommit Resources and Operations (p. 245)
• Understanding Resource Ownership (p. 246)
• Managing Access to Resources (p. 246)
• Resource Scoping in AWS CodeCommit (p. 247)
• Specifying Policy Elements: Resources, Actions, Effects, and Principals (p. 248)
• Specifying Conditions in a Policy (p. 248)
Repository arn:aws:codecommit:region:account-id:repository-name
Note
Most AWS services treat a colon (:) or a forward slash (/) in ARNs as the same character.
However, AWS CodeCommit requires an exact match in resource patterns and rules. When
creating event patterns, be sure to use the correct ARN characters so that they match the ARN
syntax in the resource.
For example, you can indicate a specific repository (MyDemoRepo) in your statement using its ARN as
follows:
"Resource": "arn:aws:codecommit:us-west-2:111111111111:MyDemoRepo"
To specify all repositories that belong to a specific account, use the wildcard character (*) as follows:
"Resource": "arn:aws:codecommit:us-west-2:111111111111:*"
To specify all resources, or if a specific API action does not support ARNs, use the wildcard character (*) in
the Resource element as follows:
"Resource": "*"
You can also use the wildcard character(*) to specify all resources that match part of a repository name.
For example, the following ARN specifies any AWS CodeCommit repository that begins with the name
MyDemo and that is registered to the AWS account 111111111111 in the us-east-2 AWS Region:
arn:aws:codecommit:us-east-2:111111111111:MyDemo*
For a list of available operations that work with the AWS CodeCommit resources, see AWS CodeCommit
Permissions Reference (p. 262).
• If you create an IAM user in your AWS account and grant permissions to create AWS CodeCommit
resources to that user, the user can create AWS CodeCommit resources. However, your AWS account, to
which the user belongs, owns the AWS CodeCommit resources.
• If you use the root account credentials of your AWS account to create a rule, your AWS account is the
owner of the AWS CodeCommit resource.
• If you create an IAM role in your AWS account with permissions to create AWS CodeCommit resources,
anyone who can assume the role can create AWS CodeCommit resources. Your AWS account, to which
the role belongs, owns the AWS CodeCommit resources.
Permissions policies that are attached to an IAM identity are referred to as identity-based policies (IAM
policies). Permissions policies that are attached to a resource are referred to as resource-based policies.
Currently, AWS CodeCommit supports only identity-based policies (IAM policies).
Topics
• Identity-Based Policies (IAM Policies) (p. 246)
• Resource-Based Policies (p. 247)
• Attach a permissions policy to a user or a group in your account – To grant a user permissions
to view AWS CodeCommit resources in the AWS CodeCommit console, attach an identity-based
permissions policy to a user or group that the user belongs to.
• Attach a permissions policy to a role (to grant cross-account permissions) – Delegation, such
as when you want to grant cross-account access, involves setting up a trust between the account
that owns the resource (the trusting account), and the account that contains the users who need to
access the resource (the trusted account). A permissions policy grants the user of a role the needed
permissions to carry out the intended tasks on the resource. A trust policy specifies which trusted
accounts are allowed to grant its users permissions to assume the role. For more information, see IAM
Terms and Concepts.
To grant cross-account permissions, attach an identity-based permissions policy to an IAM role. For
example, the administrator in Account A can create a role to grant cross-account permissions to
another AWS account (for example, Account B) or an AWS service as follows:
1. Account A administrator creates an IAM role and attaches a permissions policy to the role that
grants permissions on resources in Account A.
2. Account A administrator attaches a trust policy to the role identifying Account B as the principal
who can assume the role.
3. Account B administrator can then delegate permissions to assume the role to any users in Account
B. Doing this allows users in Account B to create or access resources in Account A. If you want to
grant an AWS service permission to assume the role, the principal in the trust policy can also be an
AWS service principal. For more information, see Delegation in IAM Terms and Concepts.
For more information about using IAM to delegate permissions, see Access Management in the IAM
User Guide.
The following example policy allows a user to create a branch in a repository named MyDemoRepo:
{
"Version": "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"codecommit:CreateBranch"
],
"Resource" : "arn:aws:codecommit:us-east-2:111111111111:MyDemoRepo"
}
]
}
To restrict the calls and resources that users in your account have access to, create specific IAM policies,
and then attach those policies to IAM users. For more information about how to create IAM roles and
to explore example IAM policy statements for AWS CodeCommit, see Overview of Managing Access
Permissions to Your AWS CodeCommit Resources (p. 244).
Resource-Based Policies
Some services, such as Amazon S3, also support resource-based permissions policies. For example, you
can attach a resource-based policy to an S3 bucket to manage access permissions to that bucket. AWS
CodeCommit doesn't support resource-based policies.
ListRepositories permission to a resource. Instead, you must scope it to all resources (using the
wildcard *). Otherwise, the action fails.
Some API operations can require permissions for more than one action. For more information about
resources and API operations, see AWS CodeCommit Resources and Operations (p. 245) and AWS
CodeCommit Permissions Reference (p. 262).
• Resource – To identify the resource that the policy applies to, you use an Amazon Resource Name
(ARN). For more information, see AWS CodeCommit Resources and Operations (p. 245).
• Action – To identify resource operations that you want to allow or deny, you use action keywords. For
example, depending on the specified Effect, the codecommit:GetBranch permission either allows
or denies the user to perform the GetBranch operation, which gets details about a branch in an AWS
CodeCommit repository.
• Effect – You specify the effect, either allow or deny, that takes place when the user requests the
specific action. If you don't explicitly grant access to (allow) a resource, access is implicitly denied.
You can also explicitly deny access to a resource to make sure that a user cannot access it, even if a
different policy grants access.
• Principal – In identity-based policies (IAM policies), the only type of policies that AWS CodeCommit
supports, the user that the policy is attached to is the implicit principal.
To learn more about IAM policy syntax, see AWS IAM Policy Reference in the IAM User Guide.
For a table showing all of the AWS CodeCommit API actions and the resources that they apply to, see
AWS CodeCommit Permissions Reference (p. 262).
To express conditions, you use predefined condition keys. There are no condition keys specific to AWS
CodeCommit. However, there are AWS-wide condition keys that you can use as appropriate. For a
complete list of AWS-wide keys, see Available Keys for Conditions in the IAM User Guide.
Topics
• Permissions Required to Use the AWS CodeCommit Console (p. 249)
• AWS Managed (Predefined) Policies for AWS CodeCommit (p. 251)
• Customer Managed Policy Examples (p. 256)
{
"Version": "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"codecommit:BatchGetRepositories"
],
"Resource" : [
"arn:aws:codecommit:us-east-2:111111111111:MyDestinationRepo",
"arn:aws:codecommit:us-east-2:111111111111:MyDemo*"
]
}
]
}
This policy has one statement that allows a user to get information about the AWS CodeCommit
repository named MyDestinationRepo and all AWS CodeCommit repositories that start with the name
MyDemo in the us-east-2 Region.
To allow users to use the AWS CodeCommit console, the administrator must grant them permissions
for AWS CodeCommit actions. For example, you could attach the AWSCodeCommitPowerUser managed
policy or its equivalent to a user or group, as shown in the following permissions policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:BatchGet*",
"codecommit:Get*",
"codecommit:List*",
"codecommit:Create*",
"codecommit:DeleteBranch",
"codecommit:Describe*",
"codecommit:Put*",
"codecommit:Post*",
"codecommit:Merge*",
"codecommit:Test*",
"codecommit:Update*",
"codecommit:GitPull",
"codecommit:GitPush"
],
"Resource": "*"
},
{
"Sid": "CloudWatchEventsCodeCommitRulesAccess",
"Effect": "Allow",
"Action": [
"events:DeleteRule",
"events:DescribeRule",
"events:DisableRule",
"events:EnableRule",
"events:PutRule",
"events:PutTargets",
"events:RemoveTargets",
"events:ListTargetsByRule"
],
"Resource": "arn:aws:events:*:*:rule/codecommit*"
},
{
"Sid": "SNSTopicAndSubscriptionAccess",
"Effect": "Allow",
"Action": [
"sns:Subscribe",
"sns:Unsubscribe"
],
"Resource": "arn:aws:sns:*:*:codecommit*"
},
{
"Sid": "SNSTopicAndSubscriptionReadAccess",
"Effect": "Allow",
"Action": [
"sns:ListTopics",
"sns:ListSubscriptionsByTopic",
"sns:GetTopicAttributes"
],
"Resource": "*"
},
{
"Sid": "LambdaReadOnlyListAccess",
"Effect": "Allow",
"Action": [
"lambda:ListFunctions"
],
"Resource": "*"
},
{
"Sid": "IAMReadOnlyListAccess",
"Effect": "Allow",
"Action": [
"iam:ListUsers"
],
"Resource": "*"
},
{
"Sid": "IAMReadOnlyConsoleAccess",
"Effect": "Allow",
"Action": [
"iam:ListAccessKeys",
"iam:ListSSHPublicKeys",
"iam:ListServiceSpecificCredentials",
"iam:ListAccessKeys",
"iam:GetSSHPublicKey"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
},
{
"Sid": "IAMUserSSHKeys",
"Effect": "Allow",
"Action": [
"iam:DeleteSSHPublicKey",
"iam:GetSSHPublicKey",
"iam:ListSSHPublicKeys",
"iam:UpdateSSHPublicKey",
"iam:UploadSSHPublicKey"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
},
{
"Sid": "IAMSelfManageServiceSpecificCredentials",
"Effect": "Allow",
"Action": [
"iam:CreateServiceSpecificCredential",
"iam:UpdateServiceSpecificCredential",
"iam:DeleteServiceSpecificCredential",
"iam:ResetServiceSpecificCredential"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
}
]
}
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt",
"kms:GenerateDataKey",
"kms:GenerateDataKeyWithoutPlaintext",
"kms:DescribeKey"
For more information about encryption and AWS CodeCommit, see AWS KMS and Encryption (p. 282).
policy is an administrative-level user policy that allows users with this policy to create and manage
CloudWatch Events rules for repositories (rules whose names are prefixed with codecommit) and
Amazon SNS topics for notifications about repository-related events (topics whose names are prefixed
with codecommit), as well as administer repositories in AWS CodeCommit.
The following AWS managed policies, which you can attach to users in your account, are specific to AWS
CodeCommit:
• AWSCodeCommitFullAccess – Grants full access to AWS CodeCommit. Apply this policy only to
administrative-level users to whom you want to grant full control over AWS CodeCommit repositories
and related resources in your AWS account, including the ability to delete repositories.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:*"
],
"Resource": "*"
},
{
"Sid": "CloudWatchEventsCodeCommitRulesAccess",
"Effect": "Allow",
"Action": [
"events:DeleteRule",
"events:DescribeRule",
"events:DisableRule",
"events:EnableRule",
"events:PutRule",
"events:PutTargets",
"events:RemoveTargets",
"events:ListTargetsByRule"
],
"Resource": "arn:aws:events:*:*:rule/codecommit*"
},
{
"Sid": "SNSTopicAndSubscriptionAccess",
"Effect": "Allow",
"Action": [
"sns:CreateTopic",
"sns:DeleteTopic",
"sns:Subscribe",
"sns:Unsubscribe",
"sns:SetTopicAttributes"
],
"Resource": "arn:aws:sns:*:*:codecommit*"
},
{
"Sid": "SNSTopicAndSubscriptionReadAccess",
"Effect": "Allow",
"Action": [
"sns:ListTopics",
"sns:ListSubscriptionsByTopic",
"sns:GetTopicAttributes"
],
"Resource": "*"
},
{
"Sid": "LambdaReadOnlyListAccess",
"Effect": "Allow",
"Action": [
"lambda:ListFunctions"
],
"Resource": "*"
},
{
"Sid": "IAMReadOnlyListAccess",
"Effect": "Allow",
"Action": [
"iam:ListUsers"
],
"Resource": "*"
},
{
"Sid": "IAMReadOnlyConsoleAccess",
"Effect": "Allow",
"Action": [
"iam:ListAccessKeys",
"iam:ListSSHPublicKeys",
"iam:ListServiceSpecificCredentials",
"iam:ListAccessKeys",
"iam:GetSSHPublicKey"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
},
{
"Sid": "IAMUserSSHKeys",
"Effect": "Allow",
"Action": [
"iam:DeleteSSHPublicKey",
"iam:GetSSHPublicKey",
"iam:ListSSHPublicKeys",
"iam:UpdateSSHPublicKey",
"iam:UploadSSHPublicKey"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
},
{
"Sid": "IAMSelfManageServiceSpecificCredentials",
"Effect": "Allow",
"Action": [
"iam:CreateServiceSpecificCredential",
"iam:UpdateServiceSpecificCredential",
"iam:DeleteServiceSpecificCredential",
"iam:ResetServiceSpecificCredential"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
}
]
}
• AWSCodeCommitPowerUser – Allows users access to all of the functionality of AWS CodeCommit and
repository-related resources, except it does not allow them to delete AWS CodeCommit repositories
or create or delete repository-related resources in other AWS services, such as Amazon CloudWatch
Events. We recommend that you apply this policy to most users.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:BatchGet*",
"codecommit:Get*",
"codecommit:List*",
"codecommit:Create*",
"codecommit:DeleteBranch",
"codecommit:Describe*",
"codecommit:Put*",
"codecommit:Post*",
"codecommit:Merge*",
"codecommit:Test*",
"codecommit:Update*",
"codecommit:GitPull",
"codecommit:GitPush"
],
"Resource": "*"
},
{
"Sid": "CloudWatchEventsCodeCommitRulesAccess",
"Effect": "Allow",
"Action": [
"events:DeleteRule",
"events:DescribeRule",
"events:DisableRule",
"events:EnableRule",
"events:PutRule",
"events:PutTargets",
"events:RemoveTargets",
"events:ListTargetsByRule"
],
"Resource": "arn:aws:events:*:*:rule/codecommit*"
},
{
"Sid": "SNSTopicAndSubscriptionAccess",
"Effect": "Allow",
"Action": [
"sns:Subscribe",
"sns:Unsubscribe"
],
"Resource": "arn:aws:sns:*:*:codecommit*"
},
{
"Sid": "SNSTopicAndSubscriptionReadAccess",
"Effect": "Allow",
"Action": [
"sns:ListTopics",
"sns:ListSubscriptionsByTopic",
"sns:GetTopicAttributes"
],
"Resource": "*"
},
{
"Sid": "LambdaReadOnlyListAccess",
"Effect": "Allow",
"Action": [
"lambda:ListFunctions"
],
"Resource": "*"
},
{
"Sid": "IAMReadOnlyListAccess",
"Effect": "Allow",
"Action": [
"iam:ListUsers"
],
"Resource": "*"
},
{
"Sid": "IAMReadOnlyConsoleAccess",
"Effect": "Allow",
"Action": [
"iam:ListAccessKeys",
"iam:ListSSHPublicKeys",
"iam:ListServiceSpecificCredentials",
"iam:ListAccessKeys",
"iam:GetSSHPublicKey"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
},
{
"Sid": "IAMUserSSHKeys",
"Effect": "Allow",
"Action": [
"iam:DeleteSSHPublicKey",
"iam:GetSSHPublicKey",
"iam:ListSSHPublicKeys",
"iam:UpdateSSHPublicKey",
"iam:UploadSSHPublicKey"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
},
{
"Sid": "IAMSelfManageServiceSpecificCredentials",
"Effect": "Allow",
"Action": [
"iam:CreateServiceSpecificCredential",
"iam:UpdateServiceSpecificCredential",
"iam:DeleteServiceSpecificCredential",
"iam:ResetServiceSpecificCredential"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:BatchGet*",
"codecommit:Get*",
"codecommit:Describe*",
"codecommit:List*",
"codecommit:GitPull"
],
"Resource": "*"
},
{
"Sid": "CloudWatchEventsCodeCommitRulesReadOnlyAccess",
"Effect": "Allow",
"Action": [
"events:DescribeRule",
"events:ListTargetsByRule"
],
"Resource": "arn:aws:events:*:*:rule/codecommit*"
},
{
"Sid": "SNSSubscriptionAccess",
"Effect": "Allow",
"Action": [
"sns:ListTopics",
"sns:ListSubscriptionsByTopic",
"sns:GetTopicAttributes"
],
"Resource": "*"
},
{
"Sid": "LambdaReadOnlyListAccess",
"Effect": "Allow",
"Action": [
"lambda:ListFunctions"
],
"Resource": "*"
},
{
"Sid": "IAMReadOnlyListAccess",
"Effect": "Allow",
"Action": [
"iam:ListUsers"
],
"Resource": "*"
},
{
"Sid": "IAMReadOnlyConsoleAccess",
"Effect": "Allow",
"Action": [
"iam:ListAccessKeys",
"iam:ListSSHPublicKeys",
"iam:ListServiceSpecificCredentials",
"iam:ListAccessKeys",
"iam:GetSSHPublicKey"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
}
]
}
For more information, see AWS Managed Policies in the IAM User Guide.
Topics
• Customer Managed Identity Policy Examples (p. 257)
• Customer Managed Integration Policy Examples (p. 260)
Examples
• Example 1: Allow a User to Perform AWS CodeCommit Operations in a Single Region (p. 257)
• Example 2: Allow a User to Use Git for a Single Repository (p. 257)
• Example 3: Allow a User Connecting from a Specified IP Address Range Access to a Repository
(p. 258)
• Example 4: Deny or Allow Actions on Branches (p. 259)
{
"Version": "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"codecommit:*"
],
"Resource" : "arn:aws:codecommit:us-east-2:*"
}
]
}
The following example allows the specified user to pull from, and push to, the AWS CodeCommit
repository named MyDemoRepo:
{
"Version": "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"codecommit:GitPull",
"codecommit:GitPush"
],
"Resource" : "arn:aws:codecommit:us-east-2:111111111111:MyDemoRepo"
}
]
}
You can create a Deny policy that denies access to all users who are not within a certain IP range. For
example, you could attach the AWSCodeCommitPowerUser managed policy and a customer-managed
policy to all users who require access to your repository. The following example policy denies all AWS
CodeCommit permissions to users whose IP addresses are not within the specified IP address block of
203.0.113.0/16:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"codecommit:*"
],
"Resource": "*",
"Condition": {
"NotIpAddress": {
"aws:SourceIp": [
"203.0.113.0/16"
]
}
}
}
]
}
The following example policy allows the specified user to access an AWS CodeCommit repository named
MyDemoRepo with the equivalent permissions of the AWSCodeCommitPowerUser managed policy only
if their IP address is within the specified address block of 203.0.113.0/16:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:BatchGetRepositories",
"codecommit:CreateBranch",
"codecommit:CreateRepository",
"codecommit:Get*",
"codecommit:GitPull",
"codecommit:GitPush",
"codecommit:List*",
"codecommit:Put*",
"codecommit:Test*",
"codecommit:Update*"
],
"Resource": "arn:aws:codecommit:us-east-2:111111111111:MyDemoRepo",
"Condition": {
"IpAddress": {
"aws:SourceIp": [
"203.0.113.0/16"
]
}
}
}
]
}
For example, you can create a Deny policy that denies users the ability to make changes to a branch
named master, including deleting that branch, in a repository named MyDemoRepo. You can use this
policy with the AWSCodeCommitPowerUser managed policy. Users with these two policies applied
would be able to create and delete branches, create pull requests, and all other actions as allowed by
AWSCodeCommitPowerUser, but they would not be able to push changes to the branch named master,
add or edit a file in the master branch in the AWS CodeCommit console, or merge a pull request into the
master branch. Because Deny is applied to GitPush, you must include a Null statement in the policy, to
allow initial GitPush calls to be analyzed for validity when users make pushes from their local repos.
Tip
If you want to create a policy that applies to all branches named master in all repositories in
your AWS account, for Resource, specify an asterisk ( * ) instead of a repository ARN.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"codecommit:GitPush",
"codecommit:DeleteBranch",
"codecommit:PutFile",
"codecommit:MergePullRequestByFastForward"
],
"Resource": "arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo",
"Condition": {
"StringEqualsIfExists": {
"codecommit:References": [
"refs/heads/master"
]
},
"Null": {
"codecommit:References": false
}
}
}
]
}
The following example policy allows a user to make changes to a branch named master in all repositories
in an AWS account. You might use this policy with the AWSCodeCommitReadOnly managed policy to
allow automated pushes to the repository. Because the Effect is Allow, this example policy would not
work with managed policies such as AWSCodeCommitPowerUser.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:GitPush"
],
"Resource": "*",
"Condition": {
"StringNotEqualsIfExists": {
"codecommit:References": [
"refs/heads/master"
]
}
}
}
]
}
Examples
• Example 1: Create a Policy That Enables Cross-Account Access to an Amazon SNS Topic (p. 260)
• Example 2: Create a Policy for AWS Lambda Integration (p. 261)
However, if you want to configure your trigger to use an Amazon SNS topic in another AWS account, you
must first configure that topic with a policy that allows AWS CodeCommit to publish to that topic. From
that other account, open the Amazon SNS console, choose the topic from the list, and for Other topic
actions, choose Edit topic policy. On the Advanced tab, modify the policy for the topic to allow AWS
CodeCommit to publish to that topic. For example, if the policy is the default policy, you would modify
the policy as follows, changing the items in red italic text to match the values for your repository,
Amazon SNS topic, and account:
{
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "__default_statement_ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"SNS:Subscribe",
"SNS:ListSubscriptionsByTopic",
"SNS:DeleteTopic",
"SNS:GetTopicAttributes",
"SNS:Publish",
"SNS:RemovePermission",
"SNS:AddPermission",
"SNS:Receive",
"SNS:SetTopicAttributes"
],
"Resource": "arn:aws:sns:us-east-2:111111111111:NotMySNSTopic",
"Condition": {
"StringEquals": {
"AWS:SourceOwner": "111111111111"
}
}
},
{
"Sid": "CodeCommit-Policy_ID",
"Effect": "Allow",
"Principal": {
"Service": "codecommit.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:us-east-2:111111111111:NotMySNSTopic",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo",
"AWS:SourceAccount": "80398EXAMPLE"
}
}
}
]
}
If you want your trigger to run a Lambda function directly (instead of using an Amazon SNS topic to
invoke the Lambda function), and you do not configure the trigger in the Lambda console, you must
include a policy similar to the following in the function's resource policy:
{
"Statement":{
"StatementId":"Id-1",
"Action":"lambda:InvokeFunction",
"Principal":"codecommit.amazonaws.com",
"SourceArn":"arn:aws:codecommit:us-east-2:80398EXAMPLE:MyDemoRepo",
"SourceAccount":"80398EXAMPLE"
}
}
When manually configuring an AWS CodeCommit trigger that invokes a Lambda function, you must
also use the Lambda AddPermission command to grant permission for AWS CodeCommit to invoke the
function. For an example, see the To allow AWS CodeCommit to run a Lambda function (p. 99) section of
Create a Trigger for an Existing Lambda Function (p. 98).
For more information about resource policies for Lambda functions, see AddPermission and The Pull/
Push Event Models in the AWS Lambda Developer Guide.
When you create a permissions policy, you specify the actions in the policy's Action field. You specify
the resource value in the policy's Resource field as an ARN, with or without a wildcard character (*).
To express conditions in your AWS CodeCommit policies, use AWS-wide condition keys. For a complete
list of AWS-wide keys, see Available Keys in the IAM User Guide.
Note
To specify an action, use the codecommit: prefix followed by the API operation name (for
example, codecommit:GetRepository or codecommit:CreateRepository.
Using Wildcards
To specify multiple actions or resources, use a wildcard character (*) in your ARN. For example,
codecommit:* specifies all AWS CodeCommit actions and codecommit:Get* specifies all AWS
CodeCommit actions that begin with the word Get. The following example grants access to all
repositories with names that begin with MyDemo.
arn:aws:codecommit:us-west-2:111111111111:MyDemo*
You can use wildcards only with the repository-name resources listed in the following table. You can't
use wildcards with region or account-id resources. For more information about wildcards, see IAM
Identifiers in IAM User Guide.
Topics
• Required Permissions for Git Client Commands (p. 262)
• Permissions for Actions on Branches (p. 263)
• Permissions for Actions on Pull Requests (p. 264)
• Permissions for Actions on Individual Files (p. 266)
• Permissions for Actions on Comments (p. 266)
• Permissions for Actions on Committed Code (p. 267)
• Permissions for Actions on Repositories (p. 269)
• Permissions for Actions on Triggers (p. 270)
• Permissions for Actions on AWS CodePipeline Integration (p. 270)
IAM policy permissions apply to any Git client command where data is sent to AWS CodeCommit. For
example, if the GitPush IAM policy permission is set to Allow, a user can push the deletion of a branch
using the Git protocol. That push is unaffected by any permissions applied to the DeleteBranch
operation for that IAM user. The DeleteBranch permission applies to actions performed with the
console, the AWS CLI, the SDKs, and the API, but not the Git protocol.
GitPull and GitPush are IAM policy permissions. They are not API actions.
AWS CodeCommit Required Permissions for Actions for Git Client Commands
GitPull
Action(s): codecommit:GitPull
Required to pull information from an AWS CodeCommit repository to a local repo. This is an IAM
policy permission only, not an API action.
Resource: arn:aws:codecommit:region:account-id:repository-name
GitPush
Required to push information from a local repo to an AWS CodeCommit repository. This is an IAM
policy permission only, not an API action.
Resource: arn:aws:codecommit:region:account-id:repository-name
AWS CodeCommit API Operations and Required Permissions for Actions on Branches
CreateBranch
Action(s): codecommit:CreateBranch
Resource: arn:aws:codecommit:region:account-id:repository-name
DeleteBranch
Action(s): codecommit:DeleteBranch
Resource: arn:aws:codecommit:region:account-id:repository-name
GetBranch
Action(s): codecommit:GetBranch
Resource: arn:aws:codecommit:region:account-id:repository-name
ListBranches
Action(s): codecommit:ListBranches
Resource: arn:aws:codecommit:region:account-id:repository-name
UpdateDefaultBranch
Action(s): codecommit:UpdateDefaultBranch
Resource: arn:aws:codecommit:region:account-id:repository-name
AWS CodeCommit API Operations and Required Permissions for Actions on Pull Requests
BatchGetPullRequests
Action(s): codecommit:BatchGetPullRequests
Required to return information about one or more pull requests in an AWS CodeCommit repository.
This is an IAM policy permission only, not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
CreatePullRequest
Action(s): codecommit:CreatePullRequest
Resource: arn:aws:codecommit:region:account-id:repository-name
DescribePullRequestEvents
Action(s): codecommit:DescribePullRequestEvents
Resource: arn:aws:codecommit:region:account-id:repository-name
GetCommentsForPullRequest
Action(s): codecommit:GetCommentsForPullRequest
Resource: arn:aws:codecommit:region:account-id:repository-name
GetCommitsFromMergeBase
Action(s): codecommit:GetCommitsFromMergeBase
Required to return information about the difference between commits in the context of a potential
merge. This is an IAM policy permission only, not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetMergeConflicts
Action(s): codecommit:GetMergeConflicts
Required to return information information about merge conflicts between the source and
destination branch in a pull request.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetPullRequest
Action(s): codecommit:GetPullRequest
Resource: arn:aws:codecommit:region:account-id:repository-name
ListPullRequests
Action(s): codecommit:ListPullRequests
Resource: arn:aws:codecommit:region:account-id:repository-name
MergePullRequestByFastForward
Action(s): codecommit:MergePullRequestByFastForward
Required to close a pull request and attempt to merge the source branch into the destination branch
of a pull request using the fast-forward merge option.
Resource: arn:aws:codecommit:region:account-id:repository-name
PostCommentForPullRequest
Action(s): codecommit:PostCommentForPullRequest
Resource: arn:aws:codecommit:region:account-id:repository-name
UpdatePullRequestDescription
Action(s): codecommit:UpdatePullRequestDescription
Resource: arn:aws:codecommit:region:account-id:repository-name
UpdatePullRequestStatus
Action(s): codecommit:UpdatePullRequestStatus
Resource: arn:aws:codecommit:region:account-id:repository-name
UpdatePullRequestTitle
Action(s): codecommit:UpdatePullRequestTitle
Resource: arn:aws:codecommit:region:account-id:repository-name
AWS CodeCommit API Operations and Required Permissions for Actions on Individual Files
DeleteFile
Action(s): codecommit:DeleteFile
Required to delete a specified file from a specified branch in an AWS CodeCommit repository from
the AWS CodeCommit console.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetBlob
Action(s): codecommit:GetBlob
Required to view the encoded content of an individual file in an AWS CodeCommit repository from
the AWS CodeCommit console.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetFile
Action(s): codecommit:GetFile
Required to view the encoded content of an specified file and its metadata in an AWS CodeCommit
repository from the AWS CodeCommit console.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetFolder
Action(s): codecommit:GetFolder
Required to view the contents of a specified folder in an AWS CodeCommit repository from the AWS
CodeCommit console.
Resource: arn:aws:codecommit:region:account-id:repository-name
PutFile
Action(s): codecommit:PutFile
Required to add a new or modified file to an AWS CodeCommit repository from the AWS
CodeCommit console, AWS CodeCommit API, or the AWS CLI.
Resource: arn:aws:codecommit:region:account-id:repository-name
API, and to commands performed using the AWS CLI. For related permissions on comments in pull
requests, see Permissions for Actions on Pull Requests (p. 264).
AWS CodeCommit API Operations and Required Permissions for Actions on Repositories
DeleteCommentContent
Action(s): codecommit:DeleteCommentContent
Required to delete the content of a comment made on a change, file, or commit in a repository.
Comments cannot be deleted, but the content of a comment can be removed if the user has this
permission.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetComment
Action(s): codecommit:GetComment
Required to return information about a comment made on a change, file, or commit in an AWS
CodeCommit repository.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetCommentsForComparedCommit
Action(s): codecommit:GetCommentsForComparedCommit
Required to return information about comments made on the comparison between two commits in
an AWS CodeCommit repository.
Resource: arn:aws:codecommit:region:account-id:repository-name
PostCommentForComparedCommit
Action(s): codecommit:PostCommentForComparedCommit
Required to comment on the comparison between two commits in an AWS CodeCommit repository.
Resource: arn:aws:codecommit:region:account-id:repository-name
PostCommentReply
Action(s): codecommit:PostCommentReply
Resource: arn:aws:codecommit:region:account-id:repository-name
UpdateComment
Action(s): codecommit:UpdateComment
Required to edit a comment on a comparison between commits or on a pull request. Comments can
only be edited by the comment author.
Resource: arn:aws:codecommit:region:account-id:repository-name
that can be performed using the Git protocol. For related permissions on comments on committed code,
see Permissions for Actions on Comments (p. 266).
Explicitly denying some of these permissions might result in unexpected consequences in the AWS
CodeCommit console. For example, setting GetTree to Deny prevents users from navigating the
contents of a repository in the console, but does not block users from viewing the contents of a file in
the repository (if they are sent a link to the file in email, for example). Setting GetBlob to Deny prevents
users from viewing the contents of files, but does not block users from browsing the structure of a
repository. Setting GetCommit to Deny prevents users from retrieving details about commits. Setting
GetObjectIdentifier to Deny blocks most of the functionality of code browsing. If you set all three
of these actions to Deny in a policy, a user with that policy cannot browse code in the AWS CodeCommit
console.
AWS CodeCommit API Operations and Required Permissions for Actions on Committed Code
BatchGetCommits
Action(s): codecommit:BatchGetCommits
Required to return information about one or more commits in an AWS CodeCommit repository. This
is an IAM policy permission only, not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetCommit
Action(s): codecommit:GetCommit
Resource: arn:aws:codecommit:region:account-id:repository-name
GetCommitHistory
Action(s): codecommit:GetCommitHistory
Required to return information about the history of commits in a repository. This is an IAM policy
permission only, not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetDifferences
Action(s): codecommit:GetDifferences
Required to return information about the differences in a commit specifier (such as a branch, tag,
HEAD, commit ID, or other fully qualified reference).
Resource: arn:aws:codecommit:region:account-id:repository-name
GetObjectIdentifier
Action(s): codecommit:GetObjectIdentifier
Required to resolve blobs, trees, and commits to their identifier. This is an IAM policy permission
only, not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetReferences
Action(s): codecommit:GetReferences
Required to return all references, such as branches and tags. This is an IAM policy permission only,
not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetTree
Action(s): codecommit:GetTree
Required to view the contents of a specified tree in an AWS CodeCommit repository from the AWS
CodeCommit console. This is an IAM policy permission only, not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
AWS CodeCommit API Operations and Required Permissions for Actions on Repositories
BatchGetRepositories
Action(s): codecommit:BatchGetRepositories
Required to get information about multiple AWS CodeCommit repositories in that are in an AWS
account. In Resource, you must specify the names of all of the AWS CodeCommit repositories for
which a user is allowed (or denied) information.
Resource: arn:aws:codecommit:region:account-id:repository-name
CreateRepository
Action(s): codecommit:CreateRepository
Resource: arn:aws:codecommit:region:account-id:repository-name
DeleteRepository
Action(s): codecommit:DeleteRepository
Resource: arn:aws:codecommit:region:account-id:repository-name
GetRepository
Action(s): codecommit:GetRepository
Resource: arn:aws:codecommit:region:account-id:repository-name
ListRepositories
Action(s): codecommit:ListRepositories
Required to get a list of the names and system IDs of multiple AWS CodeCommit repositories for an
AWS account. The only allowed value for Resource for this action is all repositories (*).
Resource: *
UpdateRepositoryDescription
Action(s): codecommit:UpdateRepositoryDescription
Resource: arn:aws:codecommit:region:account-id:repository-name
UpdateRepositoryName
Action(s): codecommit:UpdateRepositoryName
Required to change the name of an AWS CodeCommit repository. In Resource, you must specify
both the AWS CodeCommit repositories that are allowed to be changed and the new repository
names.
Resource: arn:aws:codecommit:region:account-id:repository-name
AWS CodeCommit API Operations and Required Permissions for Actions on Triggers
GetRepositoryTriggers
Action(s): codecommit:GetRepositoryTriggers
Resource: arn:aws:codecommit:region:account-id:repository-name
PutRepositoryTriggers
Action(s): codecommit:PutRepositoryTriggers
Resource: arn:aws:codecommit:region:account-id:repository-name
TestRepositoryTriggers
Action(s): codecommit:TestRepositoryTriggers
Required to test the functionality of a repository trigger by sending data to the topic or function
configured for the trigger.
Resource: arn:aws:codecommit:region:account-id:repository-name
AWS CodeCommit API Operations and Required Permissions for Actions on AWS CodePipeline
Integration
GetBranch
Action(s): codecommit:GetBranch
Resource: arn:aws:codecommit:region:account-id:repository-name
GetCommit
Action(s): codecommit:GetCommit
Resource: arn:aws:codecommit:region:account-id:repository-name
UploadArchive
Action(s): codecommit:UploadArchive
Required to allow the service role for AWS CodePipeline to upload repository changes into a
pipeline. This is an IAM policy permission only, not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
GetUploadArchiveStatus
Action(s): codecommit:GetUploadArchiveStatus
Required to determine the status of an archive upload: whether it is in progress, complete, cancelled,
or if an error occurred. This is an IAM policy permission only, not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
CancelUploadArchive
Action(s): codecommit:CancelUploadArchive
Required to cancel the uploading of an archive to a pipeline. This is an IAM policy permission only,
not an API action that you can call.
Resource: arn:aws:codecommit:region:account-id:repository-name
Topics
• Regions and Git Connection Endpoints for AWS CodeCommit (p. 272)
• Limits in AWS CodeCommit (p. 277)
• Temporary Access to AWS CodeCommit Repositories (p. 279)
• AWS Key Management Service and Encryption for AWS CodeCommit Repositories (p. 282)
• Logging AWS CodeCommit API Calls with AWS CloudTrail (p. 283)
• AWS CodeCommit Command Line Reference (p. 289)
• Basic Git Commands (p. 291)
All of the examples in this guide use the same endpoint URL for Git in US East (Ohio): git-
codecommit.us-east-2.amazonaws.com. However, when you use Git and configure your
connections, make sure you choose the Git connection endpoint that matches the region that hosts your
AWS CodeCommit repository. For example, if you want to make a connection to a repository in US East
(N. Virginia), use the endpoint URL of git-codecommit.us-east-1.amazonaws.com. This is also true
for API calls. When you make connections to an AWS CodeCommit repository with the AWS CLI or the
SDKs, make sure you use the correct regional endpoint for the repository.
Topics
• Supported Regions for AWS CodeCommit (p. 272)
• Git Connection Endpoints (p. 273)
• Server Fingerprints for AWS CodeCommit (p. 275)
• US East (Ohio)
• US East (N. Virginia)
• US West (N. California)
• US West (Oregon)
• EU (Ireland)
• EU (London)
• EU (Paris)
• EU (Frankfurt)
AWS CodeCommit has added support for the Federal Information Processing Standard (FIPS) Publication
140-2 government standard in some regions. For more information about FIPS and FIPS endpoints,
see Federal Information Processing Standard (FIPS) 140-2 Overview. For Git connection endpoints that
support FIPS, see Git Connection Endpoints (p. 273).
For more information about regional endpoints for AWS CLI, service, and API calls to AWS CodeCommit,
see AWS Regions and Endpoints.
• US East (Ohio)
• US East (N. Virginia)
• US West (N. California)
• US West (Oregon)
• EU (Ireland)
• EU (London)
• EU (Paris)
• EU (Frankfurt)
• Asia Pacific (Tokyo)
• Asia Pacific (Singapore)
• Asia Pacific (Sydney)
• Asia Pacific (Seoul)
• Asia Pacific (Mumbai)
• South America (São Paulo)
• Canada (Central)
Number of references in a single push Maximum of 4,000, including create, delete, and
update. There is no limit on the overall number of
references in the repository.
User names in commits made in the console Any combination of allowed characters between 1
and 1,024 characters in length.
Email addresses in commits made in the console Any combination of allowed characters between 1
and 256 characters in length. Email addresses are
not validated.
/./
/../
//
• end with a trailing slash or backslash
Custom data for triggers This is a string field limited to 1,000 characters. It
cannot be used to pass any dynamic parameters.
Graph display of branches in the Commit 35 per page. If there are more than 35 branches
Visualizer on a single page, the graph is not displayed.
You can also configure access for users who want or must authenticate through methods such as:
Note
The following information applies only to the use of the AWS CLI credential helper to connect to
AWS CodeCommit repositories. You cannot use SSH or Git credentials and HTTPS to connect to
AWS CodeCommit repositories with temporary access credentials.
To give users temporary access to your AWS CodeCommit repositories, complete the following steps.
Do not complete these steps if all of the following requirements are true:
Amazon EC2 instances that meet the preceding requirements are already set up to communicate
temporary access credentials to AWS CodeCommit on your behalf.
• For cross-account access, see Walkthrough: Delegating Access Across AWS Accounts Using IAM Roles.
• For SAML and federation, see Using Your Organization's Authentication System to Grant Access to
AWS Resources and About AWS STS SAML 2.0-based Federation.
• For MFA, see Using Multi-Factor Authentication (MFA) Devices with AWS and Creating Temporary
Security Credentials to Enable Access for IAM Users.
• For Login with Amazon, Amazon Cognito, Facebook, Google, or any OIDC-compatible identity provider,
see About AWS STS Web Identity Federation.
Use the information in Authentication and Access Control for AWS CodeCommit (p. 243) to specify the
AWS CodeCommit permissions you want to temporarily grant the user.
• For cross-account access, call the AWS CLI assume-role command or call the AWS STS AssumeRole API.
• For SAML, call the AWS CLI assume-role-with-saml command or the AWS STS AssumeRoleWithSAML
API.
• For federation, call the AWS CLI assume-role or get-federation-token commands or the AWS STS
AssumeRole or GetFederationToken APIs.
• For MFA, call the AWS CLI get-session-token command or the AWS STS GetSessionToken API.
• For Login with Amazon, Amazon Cognito, Facebook, Google, or any OIDC-compatible
identity provider, call the AWS CLI assume-role-with-web-identity command or the AWS STS
AssumeRoleWithWebIdentity API.
Your user should receive a set of temporary access credentials, which include an AWS access key ID, a
secret access key, and a session token. Your user should make a note of these three values because they
are used in the next step.
1. Follow the instructions in Setting Up (p. 4) to set up the AWS CLI. Use the aws configure command
to configure a profile.
Note
Before you continue, make sure the git config file is configured to use the AWS profile you
configured in the AWS CLI.
2. You can associate the temporary access credentials with the user's AWS CLI named profile in one of
the following ways. Do not use the aws configure command.
[CodeCommitProfileName]
aws_access_key_id=TheAccessKeyID
aws_secret_access_key=TheSecretAccessKey
aws_session_token=TheSessionToken
-OR-
• Set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN
environment variables:
export AWS_ACCESS_KEY_ID=TheAccessKey
export AWS_SECRET_ACCESS_KEY=TheSecretAccessKey
export AWS_SESSION_TOKEN=TheSessionToken
For Windows:
set AWS_ACCESS_KEY_ID=TheAccessKey
set AWS_SECRET_ACCESS_KEY=TheSecretAccessKey
set AWS_SESSION_TOKEN=TheSessionToken
For more information, see Configuring the AWS Command Line Interface in the AWS Command Line
Interface User Guide.
3. Set up the Git credential helper with the AWS CLI named profile associated with the temporary
access credentials.
As you follow these steps, do not call the aws configure command. You already specified temporary
access credentials through the credentials file or the environment variables. If you use environment
variables instead of the credentials file, in the Git credential helper, specify default as the profile
name.
When the user uses the AWS CLI and specifies the AWS CLI named profile associated with the temporary
access credentials, results scoped to that profile are returned.
If the user receives the 403: Forbidden error in response to calling a Git command or a command
in the AWS CLI, it's likely the temporary access credentials have expired. The user must go back to step
2 (p. 280) and get a new set of temporary access credentials.
The first time you create an AWS CodeCommit repository in a new region in your AWS account, AWS
CodeCommit creates an AWS-managed key in that same region in AWS Key Management Service (AWS
KMS) that is used only by AWS CodeCommit (the aws/codecommit key). This key is created and stored
in your AWS account. AWS CodeCommit uses this AWS-managed key to encrypt and decrypt the data in
this and all other AWS CodeCommit repositories within that region in your AWS account.
Important
AWS CodeCommit performs the following AWS KMS actions against the default key aws/
codecommit. An IAM user does not need explicit permissions for these actions, but the user
must not have any attached policies that deny these actions for the aws/codecommit key.
Specifically, your AWS account must not have any of the following permissions set to deny when
creating your first repository:
• "kms:Encrypt"
• "kms:Decrypt"
• "kms:ReEncrypt"
• "kms:GenerateDataKey"
• "kms:GenerateDataKeyWithoutPlaintext"
• "kms:DescribeKey"
To see information about the AWS-managed key generated by AWS CodeCommit, do the following:
1. Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2. In the service navigation pane, choose Encryption Keys. (If a welcome page appears, choose Get
Started Now.)
3. In Filter, choose the region for your repository. For example, if the repository was created in us-
east-2, make sure the filter is set to US East (Ohio).
4. In the list of encryption keys, choose the AWS-managed key with the alias aws/codecommit. Basic
information about the AWS-managed key will be displayed.
You cannot change or delete this AWS-managed key. You cannot use a customer-managed key in AWS
KMS to encrypt or decrypt data in AWS CodeCommit repositories.
Encryption Context
Each service integrated with AWS KMS specifies an encryption context for both the encryption and
decryption operations. The encryption context is additional authenticated information AWS KMS uses
to check for data integrity. When specified for the encryption operation, it must also be specified in the
decryption operation or decryption will fail. AWS CodeCommit uses the AWS CodeCommit repository ID
for the encryption context. You can find the repository ID by using the get-repository command or by
viewing repository details in the AWS CodeCommit console. Search for the AWS CodeCommit repository
ID in AWS CloudTrail logs to understand which encryption operations were taken on which key in AWS
KMS to encrypt or decrypt data in the AWS CodeCommit repository.
For more information about AWS KMS, see the AWS Key Management Service Developer Guide.
To learn more about CloudTrail, see the AWS CloudTrail User Guide.
For an ongoing record of events in your AWS account, including events for AWS CodeCommit, create a
trail. A trail enables CloudTrail to deliver log files to an Amazon S3 bucket. By default, when you create
a trail in the console, the trail applies to all regions. The trail logs events from all regions in the AWS
partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can
configure other AWS services to further analyze and act upon the event data collected in CloudTrail logs.
For more information, see:
When CloudTrail logging is enabled in your AWS account, API calls made to AWS CodeCommit actions
are tracked in CloudTrail log files, where they are written with other AWS service records. CloudTrail
determines when to create and write to a new file based on a time period and file size.
All AWS CodeCommit actions are logged by CloudTrail, including some (such as
GetObjectIdentifier) that are not currently documented in the AWS CodeCommit API Reference
but are instead referenced as access permissions and documented in AWS CodeCommit Permissions
Reference (p. 262). For example, calls to the ListRepositories (in the AWS CLI, aws codecommit
list-repositories), CreateRepository (aws codecommit create-repository) and
PutRepositoryTriggers (aws codecommit put-repository-triggers) actions generate entries
in the CloudTrail log files, as well as Git client calls to GitPull and GitPush. In addition, if you have an
AWS CodeCommit repository configured as a source for a pipeline in AWS CodePipeline, you will see calls
to AWS CodeCommit access permission actions such as UploadArchive from AWS CodePipeline. Since
AWS CodeCommit uses AWS Key Management Service to encrypt and decrypt repositories, you will also
see calls from AWS CodeCommit to Encrypt and Decrypt actions from AWS KMS in CloudTrail logs.
Every log entry contains information about who generated the request. The user identity information in
the log entry helps you determine the following:
• Whether the request was made with root or IAM user credentials
• Whether the request was made with temporary security credentials for a role or federated user, or
made by an assumed role
• Whether the request was made by another AWS service
You can store your log files in your Amazon S3 bucket for as long as you want, but you can also define
Amazon S3 lifecycle rules to archive or delete log files automatically. By default, your log files are
encrypted with Amazon S3 server-side encryption (SSE).
Contents
• Example: A log entry for listing AWS CodeCommit repositories (p. 285)
• Example: A log entry for creating an AWS CodeCommit repository (p. 285)
• Examples: Log entries for Git pull calls to an AWS CodeCommit repository (p. 286)
• Example: A log entry for a successful push to an AWS CodeCommit repository (p. 288)
{
"eventVersion":"1.05",
"userIdentity": {
"type":"IAMUser",
"principalId":"AIDACKCEVSQ6C2EXAMPLE",
"arn":"arn:aws:iam::444455556666:user/Mary_Major",
"accountId":"444455556666",
"accessKeyId":"AKIAIOSFODNN7EXAMPLE",
"userName":"Mary_Major"
},
"eventTime":"2016-12-14T17:57:36Z",
"eventSource":"codecommit.amazonaws.com",
"eventName":"ListRepositories",
"awsRegion":"us-east-1",
"sourceIPAddress":"203.0.113.12",
"userAgent":"aws-cli/1.10.53 Python/2.7.9 Windows/8 botocore/1.4.43",
"requestParameters":null,
"responseElements":null,
"requestID":"cb8c167e-EXAMPLE",
"eventID":"e3c6f4ce-EXAMPLE",
"readOnly":true,
"eventType":"AwsApiCall",
"apiVersion":"2015-04-13",
"recipientAccountId":"444455556666"
}
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDACKCEVSQ6C2EXAMPLE",
"arn": "arn:aws:iam::444455556666:user/Mary_Major",
"accountId": "444455556666",
"accessKeyId": "AKIAIOSFODNN7EXAMPLE",
"userName":"Mary_Major"
},
"eventTime": "2016-12-14T18:19:15Z",
"eventSource": "codecommit.amazonaws.com",
"eventName": "CreateRepository",
"awsRegion": "us-east-2",
"sourceIPAddress": "203.0.113.12",
"userAgent": "aws-cli/1.10.53 Python/2.7.9 Windows/8 botocore/1.4.43",
"requestParameters": {
"repositoryDescription": "Creating a demonstration repository.",
"repositoryName": "MyDemoRepo"
},
"responseElements": {
"repositoryMetadata": {
"arn": "arn:aws:codecommit:us-east-2:111122223333:MyDemoRepo",
"creationDate": "Dec 14, 2016 6:19:14 PM",
"repositoryId": "8afe792d-EXAMPLE",
"cloneUrlSsh": "ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo",
"repositoryName": "MyDemoRepo",
"accountId": "111122223333",
"cloneUrlHttp": "https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo",
"repositoryDescription": "Creating a demonstration repository.",
"lastModifiedDate": "Dec 14, 2016 6:19:14 PM"
}
},
"requestID": "d148de46-EXAMPLE",
"eventID": "740f179d-EXAMPLE",
"readOnly": false,
"resources": [
{
"ARN": "arn:aws:codecommit:us-east-2:111122223333:MyDemoRepo",
"accountId": "111122223333",
"type": "AWS::CodeCommit::Repository"
}
],
"eventType": "AwsApiCall",
"apiVersion": "2015-04-13",
"recipientAccountId": "111122223333"
}
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDACKCEVSQ6C2EXAMPLE",
"arn": "arn:aws:iam::444455556666:user/Mary_Major",
"accountId": "444455556666",
"accessKeyId": "AKIAIOSFODNN7EXAMPLE",
"userName":"Mary_Major"
},
"eventTime": "2016-12-14T18:19:15Z",
"eventSource": "codecommit.amazonaws.com",
"eventName": "GitPull",
"awsRegion": "us-east-2",
"sourceIPAddress": "203.0.113.12",
"userAgent": "git/2.11.0.windows.1",
"requestParameters": null,
"responseElements": null,
"additionalEventData": {
"protocol": "HTTP",
"dataTransferred": false,
"repositoryName": "MyDemoRepo",
"repositoryId": "8afe792d-EXAMPLE",
},
"requestID": "d148de46-EXAMPLE",
"eventID": "740f179d-EXAMPLE",
"readOnly": true,
"resources": [
{
"ARN": "arn:aws:codecommit:us-east-2:111122223333:MyDemoRepo",
"accountId": "111122223333",
"type": "AWS::CodeCommit::Repository"
}
],
"eventType": "AwsApiCall",
"recipientAccountId": "111122223333"
}
The following example shows a CloudTrail log entry that demonstrates the GitPull action where the
local repo is not up-to-date and so data is transferred from the AWS CodeCommit repository to the local
repo.
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDACKCEVSQ6C2EXAMPLE",
"arn": "arn:aws:iam::444455556666:user/Mary_Major",
"accountId": "444455556666",
"accessKeyId": "AKIAIOSFODNN7EXAMPLE",
"userName":"Mary_Major"
},
"eventTime": "2016-12-14T18:19:15Z",
"eventSource": "codecommit.amazonaws.com",
"eventName": "GitPull",
"awsRegion": "us-east-2",
"sourceIPAddress": "203.0.113.12",
"userAgent": "git/2.10.1",
"requestParameters": null,
"responseElements": null,
"additionalEventData": {
"protocol": "HTTP",
"capabilities": [
"multi_ack_detailed",
"side-band-64k",
"thin-pack"
],
"dataTransferred": true,
"repositoryName": "MyDemoRepo",
"repositoryId": "8afe792d-EXAMPLE",
"shallow": false
},
"requestID": "d148de46-EXAMPLE",
"eventID": "740f179d-EXAMPLE",
"readOnly": true,
"resources": [
{
"ARN": "arn:aws:codecommit:us-east-2:111122223333:MyDemoRepo",
"accountId": "111122223333",
"type": "AWS::CodeCommit::Repository"
}
],
"eventType": "AwsApiCall",
"recipientAccountId": "111122223333"
}
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDACKCEVSQ6C2EXAMPLE",
"arn": "arn:aws:iam::444455556666:user/Mary_Major",
"accountId": "444455556666",
"accessKeyId": "AKIAIOSFODNN7EXAMPLE",
"userName":"Mary_Major"
},
"eventTime": "2016-12-14T18:19:15Z",
"eventSource": "codecommit.amazonaws.com",
"eventName": "GitPush",
"awsRegion": "us-east-2",
"sourceIPAddress": "203.0.113.12",
"userAgent": "git/2.10.1",
"requestParameters": null,
"responseElements": null,
"additionalEventData": {
"protocol": "HTTP",
"dataTransferred": false,
"repositoryName": "MyDemoRepo",
"repositoryId": "8afe792d-EXAMPLE",
},
"requestID": "d148de46-EXAMPLE",
"eventID": "740f179d-EXAMPLE",
"readOnly": true,
"resources": [
{
"ARN": "arn:aws:codecommit:us-east-2:111122223333:MyDemoRepo",
"accountId": "111122223333",
"type": "AWS::CodeCommit::Repository"
}
],
"eventType": "AwsApiCall",
"recipientAccountId": "111122223333"
},
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDACKCEVSQ6C2EXAMPLE",
"arn": "arn:aws:iam::444455556666:user/Mary_Major",
"accountId": "444455556666",
"accessKeyId": "AKIAIOSFODNN7EXAMPLE",
"userName":"Mary_Major"
},
"eventTime": "2016-12-14T18:19:15Z",
"eventSource": "codecommit.amazonaws.com",
"eventName": "GitPush",
"awsRegion": "us-east-2",
"sourceIPAddress": "203.0.113.12",
"userAgent": "git/2.10.1",
"requestParameters": {
"references": [
{
"commit": "100644EXAMPLE",
"ref": "refs/heads/master"
}
]
},
"responseElements": null,
"additionalEventData": {
"protocol": "HTTP",
"capabilities": [
"report-status",
"side-band-64k"
],
"dataTransferred": true,
"repositoryName": "MyDemoRepo",
"repositoryId": "8afe792d-EXAMPLE",
},
"requestID": "d148de46-EXAMPLE",
"eventID": "740f179d-EXAMPLE",
"readOnly": false,
"resources": [
{
"ARN": "arn:aws:codecommit:us-east-2:111122223333:MyDemoRepo",
"accountId": "111122223333",
"type": "AWS::CodeCommit::Repository"
}
],
"eventType": "AwsApiCall",
"recipientAccountId": "111122223333"
}
1. On your local machine, download and install the AWS CLI. This is a prerequisite for interacting with
AWS CodeCommit from the command line. For more information, see Getting Set Up with the AWS
Command Line Interface.
Note
AWS CodeCommit works only with AWS CLI versions 1.7.38 and later. To determine which
version of the AWS CLI you have installed, run the aws --version command.
To upgrade an older version of the AWS CLI to the latest version, see Installing the AWS
Command Line Interface.
2. Run this command to verify the AWS CodeCommit commands for the AWS CLI are installed:
aws configure
When prompted, specify the AWS access key and AWS secret access key of the IAM user you will use
with AWS CodeCommit. Also, be sure to specify the region where the repository exists, such as us-
east-2. When prompted for the default output format, specify json. For example:
AWS Access Key ID [None]: Type your target AWS access key ID here, and then press Enter
AWS Secret Access Key [None]: Type your target AWS secret access key here, and then
press Enter
Default region name [None]: Type a supported region for AWS CodeCommit here, and then
press Enter
Default output format [None]: Type json here, and then press Enter
To connect to a repository or a resource in another region, you must re-configure the AWS CLI with
the default region name for that region. Supported default region names for AWS CodeCommit
include:
• us-east-2
• us-east-1
• eu-west-1
• us-west-2
• ap-northeast-1
• ap-southeast-1
• ap-southeast-2
• eu-central-1
• ap-northeast-2
• sa-east-1
• us-west-1
• eu-west-2
• ap-south-1
• ca-central-1
For more information about AWS CodeCommit and regions, see Regions and Git Connection
Endpoints (p. 272). For more information about IAM, access keys, and secret keys, see How Do I Get
Credentials? and Managing Access Keys for IAM Users.
To view a list of all available AWS CodeCommit commands, run the following command:
To view information about a specific AWS CodeCommit command, run the following command, where
command-name is the name of the command (for example, create-repository):
To learn how to use the commands in AWS CLI, go to one or more of the following sections to view
descriptions and example usage:
The following are some basic examples of frequently used Git commands.
Topics
• Configuration Variables (p. 292)
• Remote Repositories (p. 292)
• Commits (p. 293)
• Branches (p. 294)
Configuration Variables
Edits a configuration file directly. Can also be used git config [--local | --global | --
to discover the location of a specific configuration system] --edit
file. To exit edit mode, typically you type :q (to
exit without saving changes) or :wq (to save
changes and then exit), and then press Enter.
Remote Repositories
Can be used to set up a connection between git remote add remote-name remote-url
a local repo and a remote repository (such as
an AWS CodeCommit repository) using the
specified nickname the local repo has for the AWS
CodeCommit repository and the specified URL to
the AWS CodeCommit repository.
Creates a local repo by making a copy of an AWS git clone remote-url local-subfolder-
CodeCommit repository at the specified URL, in name
the specified subfolder of the current folder on
the local machine. This command also creates a
remote tracking branch for each branch in the
cloned AWS CodeCommit repository and creates
and checks out an initial branch that is forked
from the current default branch in the cloned
AWS CodeCommit repository.
Shows the nickname the local repo uses for the git remote
AWS CodeCommit repository.
Shows the nickname and the URL the local git remote -v
repo uses for fetches and pushes to the AWS
CodeCommit repository.
Pushes finalized commits from the local repo git push -u remote-name branch-name
to the AWS CodeCommit repository, using the
specified nickname the local repo has for the AWS
CodeCommit repository and the specified branch.
Pulls finalized commits to the local repo from git pull remote-name branch-name
the AWS CodeCommit repository, using the
specified nickname the local repo has for the AWS
CodeCommit repository and the specified branch
Disconnects the local repo from the AWS git remote rm remote-name
CodeCommit repository, using the specified
nickname the local repo has for the AWS
CodeCommit repository.
Commits
Shows what has or hasn't been added to the git status -sb
pending commit in the local repo in a concise
format.
Shows changes between the pending commit and git diff HEAD
the latest commit in the local repo.
Adds specific files to the pending commit in the git add [file-name-1 file-name-2 file-
local repo. name-N | file-pattern]
Adds all new, modified, and deleted files to the git add
pending commit in the local repo.
Finalizes the pending commit in the local repo, git commit -m "Some meaningful commit
including specifying a commit message at the comment"
same time.
Lists recent commits in the local repo in a graph git log --graph
format.
Lists recent commits in the local repo in a git log --graph --pretty=oneline
predefined condensed format, with a graph.
Lists recent commits in the local repo in a custom git log --graph --pretty=format:"%H
format, with a graph. (%h) : %cn : %ar : %s"
Branches
Lists all branches in the local repo with an asterisk git branch
(*) displayed next to your current branch.
Lists all branches in the local repo and remote git branch -a
tracking branches in the local repo.
Creates a new branch in the local repo using the git branch new-branch-name
specified branch name.
Switches to another branch in the local repo using git checkout other-branch-name
the specified branch name.
Creates a new branch in the local repo using the git checkout -b new-branch-name
specified branch name, and then switches to it.
Pushes a new branch from the local repo to git push -u remote-name new-branch-
the AWS CodeCommit repository using the name
specified nickname the local repo has for the AWS
CodeCommit repository and the specified branch
name. Also sets up upstream tracking information
for the branch in the local repo during the push.
Creates a new branch in the local repo using the git branch --track new-branch-name
specified branch name. Then connects the new remote-name/remote-branch-name
branch in the local repo to an existing branch
in the AWS CodeCommit repository, using the
specified nickname the local repo has for the AWS
CodeCommit repository and the specified branch
name.
Merges changes from another branch in the local git merge from-other-branch-name
repo to the current branch in the local repo.
Tags
Lists all tags in the local repo. git tag
Pulls all tags from the AWS CodeCommit git fetch --tags
repository to the local repo.
Creates a "lightweight" tag in the local repo. git tag tag-name commit-id-to-point-
tag-at
Pushes a specific tag from the local repo to git push remote-name tag-name
the AWS CodeCommit repository using the
specified nickname the local repo has for the AWS
CodeCommit repository and the specified tag
name.
Pushes all tags from the local repo to the AWS git push remote-name --tags
CodeCommit repository using the specified
nickname the local repo has for the AWS
CodeCommit repository.
Deletes a tag in the AWS CodeCommit repository git push remote-name :tag-name
using the specified nickname the local repo has
for the AWS CodeCommit repository and the
specified tag name. (Note the use of the colon
(:).)
Content update (p. 296) The content in this guide has October 30, 2018
been updated to support the
new AWS CodeCommit console
experience.
AWS CodeCommit and the AWS CodeCommit has added October 25, 2018
Federal Information Processing support for the Federal
Standard (FIPS) (p. 296) Information Processing
Standard (FIPS) Publication
140-2 government standard
in some regions. For more
information about FIPS and
FIPS endpoints, see Federal
Information Processing Standard
(FIPS) 140-2 Overview. For
more information about Git
connection endpoints, see
Regions.
AWS CodeCommit adds three AWS CodeCommit has added September 27, 2018
APIs (p. 296) three APIs to support working
with files. For more information
about Git connection endpoints,
see Permissions for Actions
on Individual Files and AWS
CodeCommit API Reference.
AWS CodeCommit You can now receive notification June 29, 2018
documentation history about updates to the AWS
notification available through CodeCommit documentation by
RSS feed (p. 296) subscribing to an RSS feed.
Earlier Updates
The following table describes important changes to the documentation prior to June 29, 2018.
New topic The Limit Pushes and Merges to Branches (p. 194) topic May 16, 2018
has been added. The AWS CodeCommit Permissions
Reference (p. 262) topic has been updated.
New section The Working with Files in AWS CodeCommit February 21,
Repositories (p. 129) section has been added. The AWS 2018
CodeCommit Permissions Reference (p. 262) and Getting
Started with AWS CodeCommit Tutorial (p. 43) topics have
been updated.
New topic The Configure Cross-Account Access to an AWS CodeCommit February 21,
Repository (p. 118) topic has been added. 2018
New topic The Integrate AWS Cloud9 with AWS CodeCommit (p. 12) December 1,
topic has been added. The Product and Service 2017
Integrations (p. 68) topic has been updated with information
about AWS Cloud9.
New section The Working with Pull Requests in AWS CodeCommit November 20,
Repositories (p. 138) section has been added. 2017
The Authentication and Access Control for AWS
CodeCommit (p. 243) section has been updated with
information about permissions for pull requests and
commenting. It also includes updated managed policy
statements.
Updated topics The Product and Service Integrations (p. 68) topic has been October 11,
updated to include links for customers who want to update 2017
their existing pipelines to use Amazon CloudWatch Events to
start pipelines in response to changes in an AWS CodeCommit
repository.
New topics The Authentication and Access Control for AWS September
CodeCommit (p. 243) section has been added. It replaces the 11, 2017
Access Permissions Reference topic.
Updated topics The Manage Triggers for a Repository (p. 90) section has been August 29,
updated to reflect changes in trigger configuration. Topics and 2017
images have been updated throughout the guide to reflect
changes in the navigation bar.
New topic The Working with User Preferences (p. 204) topic has been August 3,
added. The View Tag Details (p. 186) topic has been updated. 2017
The Product and Service Integrations (p. 68) topics has been
updated with information about integrating with Amazon
CloudWatch Events.
New topics The Integrate Eclipse with AWS CodeCommit (p. 19) and June 29,
Integrate Visual Studio with AWS CodeCommit (p. 15) topics 2017
have been added.
Updated topic AWS CodeCommit is now available in two additional regions: June 29,
Asia Pacific (Mumbai), and Canada (Central). The Regions and 2017
Git Connection Endpoints (p. 272) topic has been updated.
Updated topic AWS CodeCommit is now available in four additional regions: June 6, 2017
Asia Pacific (Seoul), South America (São Paulo), US West (N.
California), and EU (London). The Regions and Git Connection
Endpoints (p. 272) topic has been updated.
Updated topic AWS CodeCommit is now available in four additional regions: May 25, 2017
Asia Pacific (Tokyo), Asia Pacific (Singapore), Asia Pacific
(Sydney), and EU (Frankfurt). The Regions and Git Connection
Endpoints (p. 272) topic has been updated to provide
information about Git connection endpoints and supported
regions for AWS CodeCommit.
New topic The Compare Branches (p. 199) topic has been added. The May 18, 2017
contents of the Working with Branches (p. 190) section
have been updated with information about using the AWS
CodeCommit console to work with branches in a repository.
New topic The Compare Commits (p. 170) topic has been added with March 28,
information about comparing commits. The structure 2017
of the user guide has been updated for working with
repositories (p. 75), commits, (p. 160), and branches (p. 190).
Updated topic The View Commit Details (p. 163) topic has been updated with January 24,
information about viewing the difference between a commit 2017
and its parent in the console, and using the get-differences
command to view differences between commits using the
AWS CLI.
New topic The Logging AWS CodeCommit API Calls with AWS January 11,
CloudTrail (p. 283) topic has been added with information 2017
about logging connections to AWS CodeCommit using AWS
CloudFormation.
New topic The For HTTPS Users Using Git Credentials (p. 5) topic has December 22,
been added with information about setting up connections to 2016
AWS CodeCommit using Git credentials over HTTPS.
Updated topic The Product and Service Integrations (p. 68) topic has been December 5,
updated to include information about integration with AWS 2016
CodeBuild.
Updated topic AWS CodeCommit is now available in another region, EU November 16,
(Ireland). The Regions and Git Connection Endpoints (p. 272) 2016
topic has been updated to provide information about Git
connection endpoints and supported regions for AWS
CodeCommit.
Updated topic AWS CodeCommit is now available in another region, US West November 14,
(Oregon). The Regions and Git Connection Endpoints (p. 272) 2016
topic has been updated to provide information about Git
connection endpoints and supported regions for AWS
CodeCommit.
New topic The Create a Trigger for a Lambda Function (p. 95) topic October 19,
has been updated to reflect the ability to create AWS 2016
CodeCommit triggers as part of creating the Lambda function.
This simplified process streamlines trigger creation and
automatically configures the trigger with the permissions
required for AWS CodeCommit to invoke the Lambda
function. The Create a Trigger for an Existing Lambda
Function (p. 98) topic has been added to include information
about creating triggers for existing Lambda functions in the
AWS CodeCommit console.
New topic AWS CodeCommit is now available in another region, US East October 17,
(Ohio). The Regions and Git Connection Endpoints (p. 272) 2016
topic has been added to provide information about Git
connection endpoints and supported regions for AWS
CodeCommit.
Topic update The Product and Service Integrations (p. 68) topic has been October 13,
updated to include information about integration with AWS 2016
Elastic Beanstalk.
Topic update The Product and Service Integrations (p. 68) topic has been October 6,
updated to include information about integration with AWS 2016
CloudFormation.
Topic update The For SSH Connections on Windows (p. 29) topic has been September
revised to provide guidance for using a Bash emulator for SSH 29, 2016
connections on Windows instead of the PuTTY suite of tools.
Topic update The View Commit Details (p. 163) and AWS CodeCommit September
Tutorial (p. 43) topics have been updated to include 14, 2016
information about the Commit Visualizer in the AWS
CodeCommit console. The Limits (p. 277) topic has been
updated with the increase to the number of references
allowed in a single push.
Topic update The View Commit Details (p. 163) and AWS CodeCommit July 28, 2016
Tutorial (p. 43) topics have been updated to include
information about viewing the history of commits in the AWS
CodeCommit console.
New topics The Migrate a Git Repository to AWS CodeCommit (p. 205) June 29,
and Migrate Local or Unversioned Content to AWS 2016
CodeCommit (p. 213) topics have been added.
Topic update Minor updates have been made to the June 22,
Troubleshooting (p. 228) and For HTTPS Connections on 2016
Windows with the AWS CLI Credential Helper (p. 38) topics.
Topic update The Product and Service Integrations (p. 68) and Access April 18,
Permissions Reference topics have been updated to include 2016
information about integration with AWS CodePipeline.
New topics The Manage Triggers for a Repository (p. 90) section has been March 7,
added. New topics include examples, including policy and 2016
code samples, of how to create, edit, and delete triggers.
New topic The Product and Service Integrations (p. 68) topic March 7,
has been added. Minor updates have been made to 2016
Troubleshooting (p. 228).
Topic update In addition to the MD5 server fingerprint, the SHA256 server December 9,
fingerprint for AWS CodeCommit has been added to For SSH 2015
Connections on Linux, macOS, or Unix (p. 25) and For SSH
Connections on Windows (p. 29).
New topic The Browse Files in a Repository (p. 130) topic October 5,
has been added. New issues have been added to 2015
Troubleshooting (p. 228). Minor improvements and fixes have
been made throughout the user guide.
New topic The For SSH Users Not Using the AWS CLI (p. 23) topic has August 5,
been added. The topics in the Setting Up (p. 4) section have 2015
been streamlined. Guidance to help users determine which
steps to follow for their operating systems and preferred
protocols has been provided.
Topic update Clarification and examples have been added to the SSH key ID July 24, 2015
steps in SSH and Linux, macOS, or Unix: Set Up the Public and
Private Keys for Git and AWS CodeCommit (p. 26) and SSH
and Windows: Set Up the Public and Private Keys for Git and
AWS CodeCommit (p. 31).
Topic update Steps in SSH and Windows: Set Up the Public and Private Keys July 22, 2015
for Git and AWS CodeCommit (p. 31) have been updated to
address an issue with IAM and saving the public key file.
Topic update Troubleshooting (p. 228) has been updated with navigation July 20, 2015
aids. More troubleshooting information for credential
keychain issues has been added.
Topic update More information about AWS Key Management Service July 17, 2015
permissions has been added to the AWS KMS and
Encryption (p. 282) and the Access Permissions Reference
topics.
Topic update Another section has been added to Troubleshooting (p. 228) July 10, 2015
with information about troubleshooting issues with AWS Key
Management Service.
Initial release This is the initial release of the AWS CodeCommit User Guide. July 9, 2015
AWS Glossary
For the latest AWS terminology, see the AWS Glossary in the AWS General Reference.