diff --git a/packages/aws-cdk/bin/cdk.ts b/packages/aws-cdk/bin/cdk.ts index 7a2355650c8a0..14ab1a2d04b98 100644 --- a/packages/aws-cdk/bin/cdk.ts +++ b/packages/aws-cdk/bin/cdk.ts @@ -111,8 +111,11 @@ async function initCommandLine() { debug('CDK toolkit version:', version.DISPLAY_VERSION); debug('Command line arguments:', argv); + const configuration = new Configuration(argv); + await configuration.load(); + const sdkProvider = await SdkProvider.withAwsCliCompatibleDefaults({ - profile: argv.profile, + profile: configuration.settings.get(['profile']), ec2creds: argv.ec2creds, httpOptions: { proxyAddress: argv.proxy, @@ -120,9 +123,6 @@ async function initCommandLine() { }, }); - const configuration = new Configuration(argv); - await configuration.load(); - const cloudFormation = new CloudFormationDeployments({ sdkProvider }); const cloudExecutable = new CloudExecutable({ diff --git a/packages/aws-cdk/lib/settings.ts b/packages/aws-cdk/lib/settings.ts index 923c90d20afa7..93e37e9d3eab3 100644 --- a/packages/aws-cdk/lib/settings.ts +++ b/packages/aws-cdk/lib/settings.ts @@ -193,6 +193,7 @@ export class Settings { language: argv.language, pathMetadata: argv.pathMetadata, assetMetadata: argv.assetMetadata, + profile: argv.profile, plugin: argv.plugin, requireApproval: argv.requireApproval, toolkitStackName: argv.toolkitStackName,