Skip to content

Unable to execute cdk commands for a different profile #558

@stefanopallicca-imagicle

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions