-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
❗Notice: CDK CLI: "The security token included in the request is invalid" when using user credentials since 2.167.0 #32120
Comments
I got the same issue in Github Actions....
Errors with... ❌ Environment aws:/// failed bootstrapping: Error: Need to perform AWS calls for account ***, but no credentials have been configured @AdamPD's solution worked for me but isn't suitable longterm. Is this related? |
It's affecting our Azure cdk deploy pipelines too. |
Also* affecting us on Bitbucket Pipelines. |
I have noticed this issue on our CI/CD pipelines as well. AWS credential configuration that has worked before has stopped working. Confirmed it was on version |
Same here. Downgraded to 2.166.0 and trying out. |
In CDK 2.167.0, got an error meesage
After downgrading, the cdk diff and deploy jobs are functioning correctly. |
Downgrading to the previous version also fixed the problem for me. |
Same for me, i have aws environment set up correctly. Downgrading to 2.166.0 fixed the issue.
|
@AdamPD (or anyone else in this thread) can you please paste the output of |
@otaviomacedo here is the -vvv output from a cdk diff, which works fine on 2.166.0 [09:08:41] [trace] SdkProvider#resolveEnvironment()
[09:08:41] [trace] SdkProvider#baseCredentialsPartition()
[09:08:41] [trace] SdkProvider#resolveEnvironment()
[09:08:41] [trace] SdkProvider#obtainBaseCredentials()
[09:08:41] [trace] SdkProvider#defaultAccount()
[09:08:41] [trace] SdkProvider#defaultCredentials()
[09:08:41] [trace] SDK#currentAccount()
[09:08:41] Retrieved account ID YYYYYYYYYYYY from disk cache
[09:08:41] [trace] SdkProvider#forEnvironment()
[09:08:41] [trace] SdkProvider#resolveEnvironment()
[09:08:41] [trace] SdkProvider#obtainBaseCredentials()
[09:08:41] [trace] SdkProvider#defaultAccount()
[09:08:41] [trace] SdkProvider#defaultCredentials()
[09:08:41] [trace] SdkProvider#withAssumedRole()
[09:08:41] Assuming role 'arn:aws:iam::XXXXXXXXXXXX:role/cdk-sbsl-infra-lookup-role-XXXXXXXXXXXX-us-east-1'.
[09:08:42] Assuming role failed: The security token included in the request is invalid
Could not assume role in target account using current credentials (which are for account YYYYYYYYYYYY) The security token included in the request is invalid . Please make sure that this role exists in the account. If it doesn't exist, (re)-bootstrap the environment with the right '--trust', using the latest version of the CDK CLI.
[09:08:42] [trace] SdkProvider#resolveEnvironment()
[09:08:42] [trace] SdkProvider#baseCredentialsPartition()
[09:08:42] [trace] SdkProvider#resolveEnvironment()
[09:08:42] [trace] SdkProvider#obtainBaseCredentials()
[09:08:42] [trace] SdkProvider#defaultAccount()
[09:08:42] [trace] SdkProvider#defaultCredentials()
[09:08:42] [trace] SDK#currentAccount()
[09:08:42] Retrieved account ID YYYYYYYYYYYY from disk cache
[09:08:42] [trace] SdkProvider#forEnvironment()
[09:08:42] [trace] SdkProvider#resolveEnvironment()
[09:08:42] [trace] SdkProvider#obtainBaseCredentials()
[09:08:42] [trace] SdkProvider#defaultAccount()
[09:08:42] [trace] SdkProvider#defaultCredentials()
[09:08:42] [trace] SdkProvider#withAssumedRole()
[09:08:42] Assuming role 'arn:aws:iam::XXXXXXXXXXXX:role/cdk-sbsl-infra-deploy-role-XXXXXXXXXXXX-us-east-1'.
[09:08:43] Assuming role failed: The security token included in the request is invalid
[09:08:43] Reading cached notices from /home/tom/.cdk/cache/notices.json
Could not assume role in target account using current credentials (which are for account YYYYYYYYYYYY) The security token included in the request is invalid . Please make sure that this role exists in the account. If it doesn't exist, (re)-bootstrap the environment with the right '--trust', using the latest version of the CDK CLI.
[09:08:43] Error: Could not assume role in target account using current credentials (which are for account YYYYYYYYYYYY) The security token included in the request is invalid . Please make sure that this role exists in the account. If it doesn't exist, (re)-bootstrap the environment with the right '--trust', using the latest version of the CDK CLI.
at SdkProvider.withAssumedRole (/usr/lib/node_modules/aws-cdk/lib/index.js:593:5643098)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SdkProvider.forEnvironment (/usr/lib/node_modules/aws-cdk/lib/index.js:593:5639480)
at async EnvironmentAccess.cachedSdkForEnvironment (/usr/lib/node_modules/aws-cdk/lib/index.js:647:7329)
at async EnvironmentAccess.prepareSdk (/usr/lib/node_modules/aws-cdk/lib/index.js:647:6285)
at async Deployments.readCurrentTemplateWithNestedStacks (/usr/lib/node_modules/aws-cdk/lib/index.js:647:8697)
at async CdkToolkit.diff (/usr/lib/node_modules/aws-cdk/lib/index.js:647:201596)
at async exec3 (/usr/lib/node_modules/aws-cdk/lib/index.js:650:18965) |
Presume this is caused by #31702, but just a hunch |
@scarytom Yes, it was. In your case, the CLI is getting credentials for one account, but trying to call another. Is there anything you can share, like your |
For us the issue is in the region, e.g. deploy -vvv
Not quite sure how it worked in older aws-cdk versions but the region is specified in
That means our stacks are deployed in the wrong region with 2.167.0 🫠 |
|
To be clear on my side, I am running this within AppVeyor on a clean build each time, and we do not have any |
Nevermind I typo'ed the region |
@otaviomacedo no, we don't us an ~/.aws/config file. Our CI system just sets the AWS credentials via This setup has been working fine for years, and now fails with 2.167.0 |
|
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.
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: #32130 |
On the Maybe that's a lead... |
Woohoo, this reproduces! IAM User credentials seem broken:
|
We have deprecated Please note The |
I can confirm the same issue happening on GHE instances too. NPM package deprecation is working as expected and our builds are clearing on |
…32134) In Node.js, if you assign `undefined` to an environment variable, that variable ends up having the string `"undefined"`. If we are using IAM user credentials, `AWS_SESSION_TOKEN` should not be set, but because we were not handling this edge case, it was getting assigned an invalid value: ``` Welcome to Node.js v22.9.0. Type ".help" for more information. > process.env.AWS_SESSION_TOKEN || process.env.AMAZON_SESSION_TOKEN undefined > process.env.AWS_SESSION_TOKEN = process.env.AWS_SESSION_TOKEN || process.env.AMAZON_SESSION_TOKEN undefined > process.env.AWS_SESSION_TOKEN 'undefined' ``` Closes #32120. - [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Hi all, we have released v2.167.1 with fixes for the reported auth issues. Please try again and report back. Reports that everything is working are equally useful as failures. |
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 #32130
Complete Error Message:
Workaround:
Revert to
2.166.0
Solution:
Upgrade to
2.167.1
Related 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:
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:
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
The text was updated successfully, but these errors were encountered: