aws-cdk: ❗Notice: CDK CLI: "The security token included in the request is invalid" when using user credentials since 2.167.0
Please add your +1 👍 to let us know you have encountered this
Status: RESOLVED
Overview:
In version 2.167.0 CLI commands, including deployments, fail with authentication errors.
This main cause is with authentication configurations that do not use AWS_SESSION_TOKEN, like IAM User credentials.
A second cause is related to the location of the region configuration, see https://github.com/aws/aws-cdk/issues/32130
Complete Error Message:
The security token included in the request is invalid
Workaround:
Revert to 2.166.0
Solution:
Upgrade to 2.167.1
Related Issues:
https://github.com/aws/aws-cdk/issues/32130
Original issue
Since version 2.167.0, deployments fail due to the inability to get the AWS account ID. The following error occurs in the verbose output of cdk synthesize/deploy:
[01:50:17] Resolving default credentials
[01:50:17] Looking up default account ID from STS
[01:50:18] Unable to determine the default AWS account (InvalidClientTokenId): The security token included in the request is invalid
This is despite having correct AWS environment variables set (AWS_DEFAULT_REGION, AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID) and aws sts get-caller-identity works correctly.
Rolling back to 2.166.0 with:
npm install -g cdk@2.166.0
resolves the issue and deployments resume as per normal.
Regression Issue
Confirmed Regression.
Last Known Working CDK Version
No response
Expected Behavior
CDK should function correctly and retrieve the account ID via the AWS credentials.
Current Behavior
CDK throws an error stating that it cannot retrieve the account ID due to security token issues.
Reproduction Steps
Upgrade to 2.167.0, use AWS environment variable credentials but don’t specify the account ID, and run cdk synthesize.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.167.0 (build 677e108)
Framework Version
No response
Node.js Version
v22.6.0
OS
Ubuntu 22.04.4 LTS
Language
.NET
Language Version
No response
Other information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 19
- Comments: 26 (14 by maintainers)
Commits related to this issue
- Pin cdk cli @2.166.0 in CI refs: https://github.com/aws/aws-cdk/issues/32120 — committed to DemocracyClub/UK-Polling-Stations by GeoWill 2 years ago
- Pin cdk cli @2.166.0 in CI refs: https://github.com/aws/aws-cdk/issues/32120 — committed to DemocracyClub/UK-Polling-Stations by GeoWill 2 years ago
- fix(cli): failure to get credentials when session token is not set (#32134) In Node.js, if you assign `undefined` to an environment variable, that variable ends up having the string `"undefined"`. I... — committed to aws/aws-cdk by otaviomacedo 2 years ago
- fix(cli): failure to get credentials when session token is not set (#32134) In Node.js, if you assign `undefined` to an environment variable, that variable ends up having the string `"undefined"`. I... — committed to aws/aws-cdk by otaviomacedo 2 years ago
- fix(cli): failure to get credentials when session token is not set (#32134) In Node.js, if you assign `undefined` to an environment variable, that variable ends up having the string `"undefined"`. I... — committed to aws/aws-cdk by otaviomacedo 2 years ago
We have deprecated
awd-cdk@2.167.0on npmjs.com while we continue our investigation.Please note The
aws-cdk-liband other@aws-cdk/*packages are not effected by the deprecation.I can confirm the same issue happening on GHE instances too. NPM package deprecation is working as expected and our builds are clearing on
2.166.0. Thanks.Also* affecting us on Bitbucket Pipelines.
There are 2 distinct problems being discussed in this thread. While they are both introduced by switching from SDKv2 to SDKv3 we should make sure to distinguish them.
The security token included in the request is invalid: seems to happen in some circumstances on CI machines, where configuration happens entirely through environment variables.Unable to determine AWS region from environment or AWS configuration (profile: "default"), defaulting to 'us-east-1': the region that is present in a credentials file is not picked up.This issue was originally created for the first issue by @AdamPD. @otbe, I will make a new issue for your error so we can discuss that there.
Edit: new issue here: https://github.com/aws/aws-cdk/issues/32130
@otaviomacedo here is the -vvv output from a cdk diff, which works fine on 2.166.0
It’s affecting our Azure cdk deploy pipelines too.