-
Notifications
You must be signed in to change notification settings - Fork 4k
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
CDK CLI commands fail with "UnauthorizedException: Session token not found or invalid" after upgrading CDK to 2.173.0 #32510
Comments
@bbmarkus Good morning. Somehow using CDK version
Executing {
"UserId": "<<SOME-ID>>:<<USERNAME>>",
"Account": "<<ACCOUNT-ID>>",
"Arn": "arn:aws:sts::<<ACCOUNT-ID>>:assumed-role/AWSReservedSSO_AdministratorAccess_<<SOME-ID>>/<<USERNAME>>"
} Could you try executing Thanks, |
Using a non-default profile, I'm able to reproduce the described error as follows:
SSO configuraton:
(Maybe notably, this is using a named profile; no default profile is configured)
#!/usr/bin/env python3
import os
import aws_cdk as cdk
from constructs import Construct
class TestStack(cdk.Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(self, construct_id, **kwargs)
cdk.aws_s3.Bucket(scope, "testBucket")
app = cdk.App()
TestStack(
app,
"TestStack",
env=cdk.Environment(
account='<account ID>',
region='us-east-2'
),
)
app.synth()
Diffing the same stack with the same SSO configuration succeeds by forcibly downgrading to
|
@wetherc Thanks for the inputs. I'm able to reproduce it by using different regions in
Below is my
Ensured to execute Just checked, this works in CDK CLI (and package) version |
This regression was definitely caused by #32456. Now that we are forcing the credential provider to use the region configured in the profile, it will do so. If the user is configured in a different region, the authentication will fail: [profile test]
sso_session = my-sso
sso_account_id = 111111111111
sso_role_name = AdministratorAccess
region = us-east-2 # wrong region
output = json
[sso-session my-sso]
sso_start_url = https://d-abcde.awsapps.com/start/#
sso_region = us-east-1 # right region
sso_registration_scopes = sso:account:access It's the same thing that happens if we don't set the region in the profile and use the wrong region in [profile test]
sso_session = my-sso
sso_account_id = 111111111111
sso_role_name = AdministratorAccess
# no region
output = json
[sso-session my-sso]
sso_start_url = https://d-abcde.awsapps.com/start/#
sso_region = us-east-2 # wrong region
sso_registration_scopes = sso:account:access |
@wetherc help me understand your use case. Why do you have different regions in the profile and in the SSO session? |
Our organization's Identity Center config / access portal / etc are all deployed into |
Comments on closed issues and PRs are hard for our team to see. |
1 similar comment
Comments on closed issues and PRs are hard for our team to see. |
… the profile (#32520) We were reading the region from the config file and passing it to the credential providers. However, in the case of SSO, this makes the credential provider use that region to do the SSO flow, which is incorrect. The region that should be used for that is the one set in the `sso_session` section of the config file. The long term solution is for all the logic for handling regions in the SDK itself, without forcing consumers to know all the intricacies of all the use cases. As a mitigation for now, we are using the non-public `parentClientConfig` while we wait for an SDK update. Fixes #32510. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Please add your +1 👍 to let us know you have encountered this
Status: RESOLVED
Overview:
This failure happens under the following conditions:
/aws/config
file.profile
section of the config.sso_session
, which is the one where the IAM Identity center was configured.Complete Error Message:
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 theclientConfig
property. TheclientConfig
is for configuring the inner auth client directly,and has the highest priority, whereas
parentClientConfig
is the upper data clientand 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
Rolling back to previous version 2.172.0 seems to fix this for us.
Regression Issue
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
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
The text was updated successfully, but these errors were encountered: