Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 7afef9c

Browse files
authored
fix(cli-integ): atmosphere credentials not used when profile is set via AWS_PROFILE (#83)
In CodeBuild, our initial credentials are configured via a profile `~/.aws/config` and set via the `AWS_PROFILE` env variable. This in turn causes the SDK to prefer the profile credentials, even after acquiring an atmosphere environment that provides static env creds: ```console @aws-sdk/credential-provider-node - defaultProvider::fromEnv WARNING: -- 741 | Multiple credential sources detected: 742 | Both AWS_PROFILE and the pair AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY static credentials are set. 743 | This SDK will proceed with the AWS_PROFILE value. 744 |   745 | However, a future version may change this behavior to prefer the ENV static credentials. 746 | Please ensure that your environment only sets either the AWS_PROFILE or the 747 | AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY pair. ``` To fix, lets unset the `AWS_PROFILE` variable if/when static env creds are used.
1 parent 0716633 commit 7afef9c

File tree

1 file changed

+5
-0
lines changed
  • packages/@aws-cdk-testing/cli-integ/lib

1 file changed

+5
-0
lines changed

packages/@aws-cdk-testing/cli-integ/lib/aws.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ export class AwsClients {
9494
AWS_ACCESS_KEY_ID: this.identity.accessKeyId,
9595
AWS_SECRET_ACCESS_KEY: this.identity.secretAccessKey,
9696
AWS_SESSION_TOKEN: this.identity.sessionToken!,
97+
98+
// unset any previously used profile because the SDK will prefer
99+
// this over static env credentials. this is relevant for tests running on CodeBuild
100+
// because we use a profile as our main credentials source.
101+
AWS_PROFILE: '',
97102
} : undefined;
98103
}
99104

0 commit comments

Comments
 (0)