Search code examples
gitaws-codebuildaws-codecommit

How can I clone repositories in AWS CodeCommit when using AWS CodeBuild?


My CodeBuild process requires me to clone some supporting libraries from AWS CodeCommit. However, since I don't have my private key on the docker image used by AWS CodeBuild, I get permission errors trying to do the checkout:

agent_1  | Host key verification failed.
agent_1  | fatal: Could not read from remote repository.

Is there a simple, recommended way for AWS CodeBuild to download code from AWS CodeCommit?


Solution

  • If you are accessing the Codecommit repository in your account and have access to that repository, then you need to configure the IAM Role attached to the build process to be able to read the remote code commit repository.

    During the creation of the build project, an IAM role would have got created with the basic permission settings, or you have would have chosen an existing IAM role.

    Either way you need to edit the IAM role and attach the Policy to access the CodeCommit resource for the CodeBuild process to perform the cloning operation.