Description
Please add your +1 👍 to let us know you have encountered this
Status: RESOLVED
Overview:
This failure happens under the following conditions:
- CLI version 2.173.0
- Credential source is SSO, configured in the
/aws/config
file. - A region is specified in the
profile
section of the config. - This region is different than the one in the
sso_session
, which is the one where the IAM Identity center was configured.
Complete Error Message:
Unable to determine the default AWS account (CredentialsProviderError): UnauthorizedException: Session token not found or invalid
Workaround:
Revert to version 2.172.0.
Solution:
In the call to the credential provider, pass the region in the parentClientConfig
property instead of in the clientConfig
property. The clientConfig
is for configuring the inner auth client directly,
and has the highest priority, whereas parentClientConfig
is the upper data client
and has lower priority than the sso_region but still higher priority than STS global region.
Related Issues:
Original issue
Describe the bug
Thiis morning after upgrading CDK installation to 2.173.0, all CDK command fail with the following error when using --verbose
Setting "CDK_DEFAULT_REGION" environment variable to eu-central-1
Unable to determine the default AWS account (CredentialsProviderError): UnauthorizedException: Session token not found or invalid
Rolling back to previous version 2.172.0 seems to fix this for us.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
2.172.0
Expected Behavior
Command executes succefully
Current Behavior
All commands fail due to UnauthorizedException when trying to determine the default account.
Reproduction Steps
- Upgraded CDK and AWS cli (cli installed using the official snap package, upgrade was done as troubleshooting step)
- Using SSO for AWS cli login (default profile, if that can make a difference, i.e. not providing --profile as part of the commands)
- Run CDK command, e.g.
cdk diff -e StackName --fail --verbose
Possible Solution
No response
Additional Information/Context
Command aws sts get-caller-identity
returns the correct information, so this doesn't seem to be an authentication or SSO config issue.
CDK CLI Version
2.173.0
Framework Version
No response
Node.js Version
22
OS
Ubuntu (WSL)
Language
TypeScript
Language Version
No response
Other information
No response
Activity
ashishdhingra commentedon Dec 13, 2024
@bbmarkus Good morning. Somehow using CDK version
2.173.0 (build b5c2189)
, I'm unable to reproduce the issue.aws sso configure
providing profile name asdefault
. This configured SSO account in~/.aws/config
file as below:aws sso login
not providing profile name so that it usesdefault
profile.cdk diff -e CdktestStackNew --fail --verbose
. It gives the below output:Executing
aws sts get-caller-identity
without profile name gives below output:Could you try executing
aws sso login
again? Unsure if your SSO session has expired.Thanks,
Ashish
wetherc commentedon Dec 13, 2024
Using a non-default profile, I'm able to reproduce the described error as follows:
aws-cli/2.18.15 Python/3.12.6 Darwin/24.2.0 exe/x86_64
2.173.0 (build b5c2189)
SSO configuraton:
(Maybe notably, this is using a named profile; no default profile is configured)
aws sso login --profile test-profile
cdk diff --profile test-profile --verbose
Diffing the same stack with the same SSO configuration succeeds by forcibly downgrading to
2.172.0 (build 0f666c5)
aws sts get-caller-identity --profile test-profile
returnsashishdhingra commentedon Dec 13, 2024
@wetherc Thanks for the inputs. I'm able to reproduce it by using different regions in
sso-session
and SSOprofile
:Below is my
SSOAdmin
profile configured in~/.aws/config
:Ensured to execute
aws sso logout --profile SSOAdmin
andaws sso login --profile SSOAdmin
to be sure.Just checked, this works in CDK CLI (and package) version
2.172.0 (build 0f666c5)
.18 remaining items