aws-cdk: CDK 1.20 Unable to determine the default AWS account
CDK v1.20 does not set CDK_DEFAULT_ACCOUNT when AWS_SESSION_TOKEN,
AWS_SECRET_ACCESS_KEY, and AWS_ACCESS_KEY_ID are set in the environment. Works fine in v1.19.
I cannot use a CLI profile because my organisation requires MFA authentication; as work around I am starting a session via boto3 and exporting the environment variables.
Reproduction Steps
$ printenv |grep -e AWS -e CDK
AWS_SESSION_TOKEN=Fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo=
AWS_DEFAULT_REGION=eu-west-2
AWS_SECRET_ACCESS_KEY=sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx8
AWS_ACCESS_KEY_ID=Axxxxxxxxxxxxxxxxxx7
$ ls ~/.aws # deliberately no profile
ls: cannot access /home/xxxxx/.aws: No such file or directory
$ npm install -g aws-cdk@1.19
$ rm -fr ~/.cdk
$ cdk synth -v 2>v1.19.stderr
$ npm install -g aws-cdk@1.20
$ rm -fr ~/.cdk
$ cdk synth -v 2>v1.20.stderr
$ diff v1.19.stderr v1.20.stderr
1c1
< CDK toolkit version: 1.19.0 (build 5597bbe)
---
> CDK toolkit version: 1.20.0 (build 021c521)
26a27
> Does not look like EC2 instance.
30d30
< Does not look like EC2 instance.
43,44c43,60
< Default account ID: 3xxxxxxxxxx2
< Setting "CDK_DEFAULT_ACCOUNT" environment variable to 3xxxxxxxxxx2
---
> Unable to determine the default AWS account (did you configure "aws configure"?): { 503:
> at Request.extractError (/xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/protocol/query.js:55:29)
> at Request.callListeners (/xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
> at Request.emit (/xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
> at Request.emit (/xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:683:14)
> at Request.transition (/xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:22:10)
> at AcceptorStateMachine.runTo (/xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:14:12)
> at /xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:26:10
> at Request.<anonymous> (/xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:38:9)
> at Request.<anonymous> (/xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:685:12)
> at Request.callListeners (/xxxxxxxxxxxxxx/.nvm/versions/node/v10.16.3/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
> message: null,
> code: 503,
> time: 2020-01-10T11:23:24.090Z,
> requestId: undefined,
> statusCode: 503,
> retryable: true }
> Setting "CDK_DEFAULT_ACCOUNT" environment variable to undefined
49c65
< CDK_DEFAULT_ACCOUNT: '3xxxxxxxxxx2',
---
> CDK_DEFAULT_ACCOUNT: undefined,
54c70
< CDK_CLI_VERSION: '1.19.0' }
---
> CDK_CLI_VERSION: '1.20.0' }
Error Log
Unable to determine the default AWS account
Environment
- CLI Version : 1.20.0
- Framework Version: 1.20.0
- OS : Linux
- Language : Python
This is 🐛 Bug Report
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (14 by maintainers)
Commits related to this issue
- fix(cli): proxy support Proxy support was broken in the PR that introduced support for custom CA bundles. Fix the support. Fixes #5743, fixes #5791. — committed to aws/aws-cdk by rix0rrr 4 years ago
- fix(cli): proxy support Proxy support was broken in the PR that introduced support for custom CA bundles. Fix the support. Fixes #5743, fixes #5791. — committed to aws/aws-cdk by rix0rrr 4 years ago
- fix(cli): proxy support is broken (#5803) Proxy support was broken in the PR that introduced support for custom CA bundles. Fix the support. Fixes #5743, fixes #5791. — committed to aws/aws-cdk by rix0rrr 4 years ago
I’ve also tried to patch it but I’m facing the same problem as @sheridansmall - this call is done in the constructor, so outside async function and await can’t be used here