Skip to content

(cli): CDK CLI is not discovering SSO Credentials  #23520

@sam-goodwin

Description

@sam-goodwin

Describe the bug

Something has changed from under me that has broken the AWS CDK CLI with SSO. This used to work before.

When I run deploy:

cdk deploy --profile=sam

I get an error:

Unable to determine the default AWS account: ProcessCredentialsProviderFailure: Profile sam did not include credential process

I dug into this - it's trying to load ProcessCredentials because the SsoCredentials is failing to load.

If you look at this code in aws-sdk, you'll notice it expects sso_start_url to be on the profile:

https://github.com/aws/aws-sdk-js/blob/ce9d028875f0766829caa3127436d8ef2fd4abdf/lib/credentials/sso_credentials.js#L105

But after running aws configure sso, my ~/aws/config doesn't contain that information on the profile - it's moved to the sso-session. I think this is new behavior?

[profile sam]
sso_session = sam
sso_account_id = <redacted>
sso_role_name = AdministratorAccess
region = us-west-2
output = json
[sso-session sam]
sso_start_url = <redacted>
sso_region = us-east-1
sso_registration_scopes = sso:account:access

Moving the properties from sso-session to the profile gets past this error, but then I get another error:

SsoCredentialsProviderFailure: Cached credentials not found under sam profile. Please make sure you log in with aws sso login first

But I have logged in. After some hacking in the .js of the aws-sdk, I discovered that it's looking for the following cache file:

.aws/sso/cache/9616dde3b3a6e3e3cf79ed3a2d8a81d96feb7baa.json

But aws sso login --profile=sam produces the following files:

dee28091556274a08d5d440787aa4df6c6267b17.json
f16bed56189e249fe4ca8ed10a1ecae60e8ceac0.json

Expected Behavior

cdk deploy --profile=sam should successfully deploy

Current Behavior

cdk deploy fails. I have provided details in the description.

Reproduction Steps

Not sure how to do that.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.50.0 (build 4c11af6)

Framework Version

No response

Node.js Version

v16.14.2

OS

Mac OS 11.5.1

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

package/toolsRelated to AWS CDK Tools or CLI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions