shell-plugins icon indicating copy to clipboard operation
shell-plugins copied to clipboard

Unable to execute cdk commands for a different profile

Open stefanopallicca-imagicle opened this issue 3 months ago • 0 comments

Platform or tool

AWS CDK

Desired or expected behavior

I'm trying to run cdk commands using a different profile from the default one. Running this command

npx cdk -c account=<lab_account_id> -c region=eu-central-1 -c config=lab diff --all --profile lab --verbose

and using the default .aws/credentials file filled with credentials works and diffs to lab profile.

Current behavior

Without credentials file, or with an empty one, the above command returns

Need to perform AWS calls for account <lab_account_id>, but no credentials have been configured

In the verbose logs, I can see:

Unable to determine the default AWS account (CredentialsProviderError): Could not resolve credentials using profile: [default] in configuration/credentials file(s).

here's my .aws/config file:

[default]
region = eu-central-1

[profile lab]
region = eu-central-1
role_arn = arn:aws:iam::<lab_account_id>:role/MyLabRole
source_profile = default

The 1password AWS plugin is currently working with this configuration (for instance, aws s3 ls --profile lab show my "lab" s3 buckets), but cdk does not. How can I solve?

Relevant log output


op CLI version

2.32.0