Skip to content

Commit 7028242

Browse files
fix(cli): assuming a role from the INI file fails in non-commercial regions (#32456)
SDK v3 is ignoring the `region` configuration if it's a non-commercial region, such as `cn-*`. This PR also removes a duplicate test suite. Fixes #32357. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent d0a4a78 commit 7028242

File tree

2 files changed

+1
-45
lines changed

2 files changed

+1
-45
lines changed

packages/aws-cdk/lib/api/aws-auth/awscli-compatible.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export class AwsCliCompatible {
3434
requestHandler: AwsCliCompatible.requestHandlerBuilder(options.httpOptions),
3535
customUserAgent: 'aws-cdk',
3636
logger: options.logger,
37+
region: await this.region(options.profile),
3738
};
38-
3939
/**
4040
* The previous implementation matched AWS CLI behavior:
4141
*

packages/aws-cdk/test/api/aws-auth/awscli-compatible.test.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -285,47 +285,3 @@ describe('Session token', () => {
285285
expect(process.env.AWS_SESSION_TOKEN).toEqual('aaa');
286286
});
287287
});
288-
289-
describe('Session token', () => {
290-
beforeEach(() => {
291-
process.env.AWS_ACCESS_KEY_ID = 'foo';
292-
process.env.AWS_SECRET_ACCESS_KEY = 'bar';
293-
});
294-
295-
test('does not mess up with session token env variables if they are undefined', async () => {
296-
// Making sure these variables are not defined
297-
delete process.env.AWS_SESSION_TOKEN;
298-
delete process.env.AMAZON_SESSION_TOKEN;
299-
300-
await AwsCliCompatible.credentialChainBuilder();
301-
302-
expect(process.env.AWS_SESSION_TOKEN).toBeUndefined();
303-
});
304-
305-
test('preserves AWS_SESSION_TOKEN if it is defined', async () => {
306-
process.env.AWS_SESSION_TOKEN = 'aaa';
307-
delete process.env.AMAZON_SESSION_TOKEN;
308-
309-
await AwsCliCompatible.credentialChainBuilder();
310-
311-
expect(process.env.AWS_SESSION_TOKEN).toEqual('aaa');
312-
});
313-
314-
test('assigns AWS_SESSION_TOKEN if it is not defined but AMAZON_SESSION_TOKEN is', async () => {
315-
delete process.env.AWS_SESSION_TOKEN;
316-
process.env.AMAZON_SESSION_TOKEN = 'aaa';
317-
318-
await AwsCliCompatible.credentialChainBuilder();
319-
320-
expect(process.env.AWS_SESSION_TOKEN).toEqual('aaa');
321-
});
322-
323-
test('preserves AWS_SESSION_TOKEN if both are defined', async () => {
324-
process.env.AWS_SESSION_TOKEN = 'aaa';
325-
process.env.AMAZON_SESSION_TOKEN = 'bbb';
326-
327-
await AwsCliCompatible.credentialChainBuilder();
328-
329-
expect(process.env.AWS_SESSION_TOKEN).toEqual('aaa');
330-
});
331-
});

0 commit comments

Comments
 (0)