aws-cdk: (cli): CDK CLI not working with SSO

Describe the bug

The cdk cli is not working with my sso profile.

If I export my profile to envars it works. So that seems like there is nothing wrong with the account and something wrong with the way cdk reads the sso profile.

I login using aws sso login --profile my-profile. When I run cdk bootstrap aws://<my-account>/<my-region> --profile my-profile there is an error Need to perform AWS calls for account 413304634307, but no credentials have been configured

Expected Behavior

I expect to be able to run:

  1. aws sso login --profile my-profile
  2. cdk bootstrap aws://my-account/my-region --profile my-profile

Current Behavior

Current behaviour is that this throws an error “Need to perform AWS calls for account 413304634307, but no credentials have been configured”

However, if I add a step to export to envars it does work.

This works: 1. aws sso login --profile my-profile 2. $(aws configure export-credentials --profile my-profile --format env) 3. cdk bootstrap aws://my-account/my-region --profile my-profile

Reproduction Steps

Run this and see the error because sso profile doesn’t work:

  1. aws sso login --profile my-profile
  2. cdk bootstrap aws://my-account/my-region --profile my-profile

Run this and it works because it has the envars it wants:

1. aws sso login --profile my-profile 2. $(aws configure export-credentials --profile my-profile --format env) 3. cdk bootstrap aws://my-account/my-region --profile my-profile

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.142.1 (build ed4e152)

Framework Version

No response

Node.js Version

v20.12.0

OS

WSL Ubuntu 22.04.4 LTS

Language

TypeScript

Language Version

No response

Other information

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 6
  • Comments: 15 (4 by maintainers)

Most upvoted comments

For those needing a solution in general you can still use the access keys provided by the AWS Access Portal homepage under the Access Key link. Use “Option 2: Add a profile to your AWS credentials file” for named profiles, adjust the profile name of the section as needed.

2024-12-17_9-41-05

credential_process = aws configure export-credentials --format process

Adding this to the respective config profile works without using an extra tool.

Bump. Seeing this as well.

No default profile in my creds file either. I updated the CLI and adjust the sso config to the new IAM Identity Center specifications here. I am using named profiles and other CLI calls are completing without issue using the profile name.

Try reconfiguring SSO. I was still set up for legacy access - switching to the new identity centre SSO config fixed this for me:

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html