CDK 1.20 Unable to determine the default AWS account
See original GitHub issueCDK 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:22 (14 by maintainers)
Top Results From Across the Web
How to resolve: 'Unable to resolve AWS account to use. It must ...
Using the --profile option to cdk commands. Using environment variables. Using the default profile as set by the AWS Command Line Interface (AWS...
Read more >awslabs/aws-cdk - Gitter
The error is Unable to resolve AWS account to use. It must be either configured when you define your CDK or through the...
Read more >Gitlab CICD & AWS CDK Deploy - Unable to determine the ...
Situtation: When I cdk deploy locally, I can deploy the stack to the correct account. However, when via gitlab-ci.yml, I get the error: ......
Read more >Troubleshooting common AWS CDK issues
(The staging bucket is used when deploying stacks that contain assets or that synthesize an AWS CloudFormation template larger than 50K.) Use an...
Read more >aws-cdk.aws-ec2 - PyPI
All default constructs require EC2 instances to be launched inside a VPC, ... in the stack - currently you're unable to get the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
I think it’s the ‘http.agent’ that missing, it was removed in the commit I mentioned.