The AWS CodeCommit Git Credentials Manager is a small library to generate GIT credentials to be used with CodeCommit. To generate these credentials, the tool will use the AWS SDK authentication toolchain. For more information about how to authenticate towards the SDK, you can read the official documentation: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html
To start using the library, you need to install it
npm install --save @eismea/aws-codecommit-git-credentials-manager
code
const credManager = new AwsCodeCommitGitCredentialsManager("eu-west-1");
console.log(await credManager.GetGitUrlWithCredentials("my-repo"));
usage
git clone <url>
where <url>
is the url logger by the code
code
const credManager = new AwsCodeCommitGitCredentialsManager("eu-west-1");
console.log(await credManager.GetAuthorizationHeader("my-repo"));
usage
git -c http.extraHeader="<authorization_header>" clone https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/my-repo
Where <authorization_header>
is the authorization header logged by the code
code
const credManager = new AwsCodeCommitGitCredentialsManager("eu-west-1");
console.log(await credManager.GetCredentials("my-repo"));
The AwsCodeCommitGitCredentialsManager library can also help you retrieve GIT credentials from AWS for CodeCommit by assuming a specified role. This can be useful when the CodeCommit repository you are trying to connect to is in a different account.
code
// Create an instance of the credentials manager
const credManager = new AwsCodeCommitGitCredentialsManager("eu-west-1", "arn:aws:iam::123456789012:role/CodeCommitReader");
// Get the GIT URL with embedded credentials
(async () => {
try {
const gitUrlWithCredentials = await credManager.GetGitUrlWithCredentials("my-repo");
console.log(gitUrlWithCredentials);
} catch (error) {
console.error("Error retrieving Git URL:", error);
}
})();
Parameters
- region ("eu-west-1" in the example): The AWS region where CodeCommit is hosted.
- assumeRoleArn ("arn:aws:iam::123456789012:role/CodeCommitReader"): The ARN of the IAM role that should be assumed to fetch the credentials.
Logging issues can be done at https://code.europa.eu/eismea/aws-codecommit-git-credentials-manager/-/issues
- Stijn Brouwers (in assignment of EISMEA)
This project uses the following open source dependencies:
Library | License | Url |
---|---|---|
@types/node | MIT | https://github.com/DefinitelyTyped/DefinitelyTyped |
@types/jest | MIT | https://github.com/DefinitelyTyped/DefinitelyTyped |
@smithy/types | Apache-2.0 | https://github.com/smithy-lang/smithy-typescript |
@aws-sdk/credential-providers | Apache-2.0 | https://github.com/aws/aws-sdk-js-v3 |
@aws-sdk/client-sts | Apache-2.0 | https://github.com/aws/aws-sdk-js-v3 |
eslint | MIT | https://github.com/eslint/eslint |
typescript | Apache-2.0 | https://github.com/Microsoft/TypeScript |
typescript-eslint | MIT | https://github.com/typescript-eslint/typescript-eslint |
jsdoc | Apache-2.0 | https://github.com/jsdoc/jsdoc |
jest | MIT | https://github.com/jestjs/jest |
ts-jest | MIT | https://github.com/kulshekhar/ts-jest |
jest-junit | Apache License 2.0 | https://github.com/jest-community/jest-junit |
See License