'How to check out a CodeCommit repo from within Codebuild?

I have an AWS CodePipeline that is attached to a codecommit repo "A". As part of the build process, I want to generate some artifacts from repo "A" and commit them to codecommit repo "B". I have tried including

git clone https://git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB

in the buildspec but I get this error in CodeBuild:

fatal: could not read Username for 'https://git-codecommit.us-west-2.amazonaws.com': No such device or address

[Container] 2022/04/27 22:26:42 Command did not exit successfully git clone https://git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB exit status 128

It seems like it does not have credentials. I have also tried including the username and password in the git command like this git clone https://codepipelineuser-at-***:***@git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB and got this error:

[Container] 2022/04/27 21:33:45 Command did not exit successfully git clone git clone https://codepipelineuser-at-***:***@git-codecommit.us-west-2.amazonaws.com/v1/repos/RepoB exit status 129
[Container] 2022/04/27 21:33:45 Phase complete: POST_BUILD State: FAILED
[Container] 2022/04/27 21:33:45 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: git clone git clone https://codepipelineuser-at-123542344134:***@git-codecommit.us-west-2.amazonaws.com/v1/repos/AmplifySpec-Kotlin. Reason: exit status 129

(I know you should never check in a password but I just did it as a test and reset the password afterwards, and the repo is empty. If that had worked I would have stored the password in Parameter Store).

How do I specify the credentials of my CodeCommit repo so I can check it out within CodeBuild?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source