Matt Healy - PropTech CTO
Technology Leader, Solutions Architect and Business Analyst
Perth, Western Australia

AWS CodeCommit is Amazon Web Service's Git hosting service and part of their suite of developer tools. It can be thought of as a comparable service to something like GitHub or GitLab although being completely honest both of those services are ahead of CodeCommit in terms of usability and feature set. It does however have the advantage of being closely tied to other AWS services, in particular IAM for permission management.

CodeCommit allows for the usual development workflow of Pull Requests. However, something annoying about this is that you can only view outstanding pull requests against a single repository. There is no way in the AWS Console to have an overview of all outstanding pull requests across all code repositories in your account (within the current region).

As someone who is responsible for performing code reviews, I found this quite frustrating in that I couldn't at a glance see how many PR's are waiting for my review and thus started to fall behind in making those reviews. As you may know from my earlier blog entries, one thing I love about AWS is that almost anything can be scripted using their API or CLI interfaces.

Using the excellent Boto3 Python library, I managed to create the below script which I find useful for summarising all outstanding pull requests in the account.

View on GitHub

import boto3
import argparse

parser = argparse.ArgumentParser()

    '--repo', metavar='repo', type=str,
    help='Optionally filter by repository')

args = parser.parse_args()
filterRepository = args.repo

client = boto3.client('codecommit')
region = client.meta.region_name

pullRequests = []

resp = client.list_repositories()
repositories = resp['repositories']

for r in repositories:

    if filterRepository:
        if r['repositoryName'] != filterRepository:

    resp = client.list_pull_requests(

    pullRequestIds = resp['pullRequestIds']
    for p in pullRequestIds:

for i in pullRequests:

    resp = client.get_pull_request(

    pr = resp['pullRequest']

    title = pr['title']
    description = pr.get('description')
    lastActivity = pr['lastActivityDate']
    created = pr['creationDate']
    authorArn = pr['authorArn']

    targets = pr['pullRequestTargets']

    for t in targets:

        repo = t['repositoryName']

        link = 'https://{}'.format(region) + \
               'codecommit/repositories/{}/pull-requests/'.format(repo) + \
               '{}?region={}'.format(i, region)


        print("\nRepo: {}".format(t['repositoryName']))
        print("Source branch: {}".format(t['sourceReference']))
        print("Target branch: {}\n".format(t['destinationReference']))

    print("Created: {}".format(created))
    print("Last Activity: {}".format(lastActivity))
    print("Author: {}\n".format(authorArn))

    print("Title: {}".format(title))
    print("Description: {}\n".format(description))