AWS CodeCommit

Site admins can sync Git repositories hosted on AWS CodeCommit with Sourcegraph so that users can search and navigate the repositories.

To set this up, add AWS CodeCommit as an external service to Sourcegraph:

  1. Go to User menu > Site admin.
  2. Open the External services page.
  3. Press + Add external service.
  4. Enter a Display name (using “AWS CodeCommit” is OK if you only have one AWS CodeCommit connection).
  5. In the Kind menu, select AWS CodeCommit.
  6. Configure the connection to AWS CodeCommit in the JSON editor. Use Cmd/Ctrl+Space for completion, and see configuration documentation below.
  7. Press Add external service.

AWS CodeCommit Git credentials

Since version 3.4 of Sourcegraph, the AWS CodeCommit service requires Git credentials in order to clone repositories via HTTPS. Git credentials consist of a username and a password that you can create in AWS IAM.

For detailed instructions on how to create the credentials in IAM, see: Setup for HTTPS Users Using Git Credentials

Configuration

AWS CodeCommit external service connections support the following configuration options, which are specified in the JSON editor in the site admin external services area.

{
	// The AWS access key ID to use when listing and updating repositories from AWS CodeCommit. Must have the AWSCodeCommitReadOnly IAM policy.
	"accessKeyID": null,

	// A list of repositories to never mirror from AWS CodeCommit. 
	//
	// Supports excluding by name ({"name": "git-codecommit.us-west-1.amazonaws.com/repo-name"}) or by ARN ({"id": "arn:aws:codecommit:us-west-1:999999999999:name"}).
	"exclude": null,
	// Other example values:
	// - [
	//     {
	//       "name": "go-monorepo"
	//     },
	//     {
	//       "id": "f001337a-3450-46fd-b7d2-650c0EXAMPLE"
	//     }
	//   ]
	// - [
	//     {
	//       "name": "go-monorepo"
	//     },
	//     {
	//       "name": "go-client"
	//     }
	//   ]

	// The Git credentials used for authentication when cloning an AWS CodeCommit repository over HTTPS.
	//
	// See the AWS CodeCommit documentation on Git credentials for CodeCommit: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_ssh-keys.html#git-credentials-code-commit.
	// For detailed instructions on how to create the credentials in IAM, see this page: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html
	"gitCredentials": null,

	// Deprecated and ignored field which will be removed entirely in the next release. AWS CodeCommit repositories can no longer be enabled or disabled explicitly. Configure which repositories should not be mirrored via "exclude" instead.
	"initialRepositoryEnablement": false,

	// The AWS region in which to access AWS CodeCommit. See the list of supported regions at https://docs.aws.amazon.com/codecommit/latest/userguide/regions.html#regions-git.
	"region": "us-east-1",

	// The pattern used to generate a the corresponding Sourcegraph repository name for an AWS CodeCommit repository. In the pattern, the variable "{name}" is replaced with the repository's name.
	//
	// For example, if your Sourcegraph instance is at https://src.example.com, then a repositoryPathPattern of "awsrepos/{name}" would mean that a AWS CodeCommit repository named "myrepo" is available on Sourcegraph at https://src.example.com/awsrepos/myrepo.
	//
	// It is important that the Sourcegraph repository name generated with this pattern be unique to this code host. If different code hosts generate repository names that collide, Sourcegraph's behavior is undefined.
	"repositoryPathPattern": "{name}",
	// Other example values:
	// - "git-codecommit.us-west-1.amazonaws.com/{name}"
	// - "git-codecommit.eu-central-1.amazonaws.com/{name}"

	// The AWS secret access key (that corresponds to the AWS access key ID set in `accessKeyID`).
	"secretAccessKey": null
}