Great code search for AWS CodeCommit

Beyang Liu

Install Sourcegraph to get great code search on AWS CodeCommit

Sourcegraph brings great code search and understanding abilities to development teams using AWS CodeCommit. Code search helps your engineering team find usage examples, debug errors, reuse existing libraries and packages, and understand unfamiliar parts of your code base more quickly. Learn more about Sourcegraph code search.

Setting up Sourcegraph code search to work with AWS CodeCommit is quick and easy.

  1. First, install and run an instance of Sourcegraph.
  2. Create a AWS IAM user with programmatic access.
  1. Attach the permission AWSCodeCommitReadOnly to this user.
  1. Create a SSH key pair:
ssh-keygen -t rsa
  1. Add the public key to the IAM user (under the "Security credentials" tab). After it is uploaded, make a note of its SSH key ID.
  1. Modify your config.json (which you created as part of installing Sourcegraph) to access your AWS CodeCommit repositories. You'll need to make two changes:

a. Set the gitOriginMap field to include a mapping of the form aws/!ssh://${YOUR_SSH_KEY_ID}@${YOUR_SSH_CLONE_URL_PREFIX}/%. Substitute the SSH key ID associated with the SSH key you added and the SSH clone URL prefix, which you can obtain by viewing the SSH clone URL of any of your repositories. It should look something like this:

"gitOriginMap": "aws/!ssh://[email protected]/v1/repos/%",

b. Copy the private SSH key to a file called id_rsa in the directory that contains your config.json. Then add the following entry:

"gitserverSSH": {
  "id_rsa": "file!id_rsa"
  1. Update your Sourcegraph instance to reflect the changes you made to your config.json by running sourcegraph-server-gen config.json ./helm-chart && helm upgrade sourcegraph ./helm-chart.
  2. Add your AWS CodeCommit repositories by navigating to https://${YOUR_SOURCEGRAPH_URL}/aws/${REPO_NAME}.

And that's it! Now you can search over all your AWS CodeCommit repositories at once or configure a search group that lets you and your team search over a targeted subset of repositories. You can also configure Sourcegraph to work with a variety of Enterprise SSO identity providers and additional code hosts. You can read more about customizations in the Sourcegraph administrator docs.

Install a self-hosted Sourcegraph instance with 1 command.

About the author

Beyang Liu is the CTO and co-founder of Sourcegraph. Beyang studied Computer Science at Stanford, where he published research in probabilistic graphical models and computer vision at the Stanford AI Lab. You can chat with Beyang on Twitter @beyang or our community Discord.

Get Cody, the AI coding assistant

Cody makes it easy to write, fix, and maintain code.