diff --git a/packages/aws-cdk/lib/api/aws-auth/awscli-compatible.ts b/packages/aws-cdk/lib/api/aws-auth/awscli-compatible.ts index c73b22ec4f2bf..319e75e3bdb79 100644 --- a/packages/aws-cdk/lib/api/aws-auth/awscli-compatible.ts +++ b/packages/aws-cdk/lib/api/aws-auth/awscli-compatible.ts @@ -34,8 +34,8 @@ export class AwsCliCompatible { requestHandler: AwsCliCompatible.requestHandlerBuilder(options.httpOptions), customUserAgent: 'aws-cdk', logger: options.logger, + region: await this.region(options.profile), }; - /** * The previous implementation matched AWS CLI behavior: * diff --git a/packages/aws-cdk/test/api/aws-auth/awscli-compatible.test.ts b/packages/aws-cdk/test/api/aws-auth/awscli-compatible.test.ts index 9d7a2ab460ab1..2b20597f3fae7 100644 --- a/packages/aws-cdk/test/api/aws-auth/awscli-compatible.test.ts +++ b/packages/aws-cdk/test/api/aws-auth/awscli-compatible.test.ts @@ -285,47 +285,3 @@ describe('Session token', () => { expect(process.env.AWS_SESSION_TOKEN).toEqual('aaa'); }); }); - -describe('Session token', () => { - beforeEach(() => { - process.env.AWS_ACCESS_KEY_ID = 'foo'; - process.env.AWS_SECRET_ACCESS_KEY = 'bar'; - }); - - test('does not mess up with session token env variables if they are undefined', async () => { - // Making sure these variables are not defined - delete process.env.AWS_SESSION_TOKEN; - delete process.env.AMAZON_SESSION_TOKEN; - - await AwsCliCompatible.credentialChainBuilder(); - - expect(process.env.AWS_SESSION_TOKEN).toBeUndefined(); - }); - - test('preserves AWS_SESSION_TOKEN if it is defined', async () => { - process.env.AWS_SESSION_TOKEN = 'aaa'; - delete process.env.AMAZON_SESSION_TOKEN; - - await AwsCliCompatible.credentialChainBuilder(); - - expect(process.env.AWS_SESSION_TOKEN).toEqual('aaa'); - }); - - test('assigns AWS_SESSION_TOKEN if it is not defined but AMAZON_SESSION_TOKEN is', async () => { - delete process.env.AWS_SESSION_TOKEN; - process.env.AMAZON_SESSION_TOKEN = 'aaa'; - - await AwsCliCompatible.credentialChainBuilder(); - - expect(process.env.AWS_SESSION_TOKEN).toEqual('aaa'); - }); - - test('preserves AWS_SESSION_TOKEN if both are defined', async () => { - process.env.AWS_SESSION_TOKEN = 'aaa'; - process.env.AMAZON_SESSION_TOKEN = 'bbb'; - - await AwsCliCompatible.credentialChainBuilder(); - - expect(process.env.AWS_SESSION_TOKEN).toEqual('aaa'); - }); -});