Skip to content
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

Unable to determine the default AWS account: TypeError: Cannot redefine property: [my-other-aws-profile] #20875

Closed
jedrekdomanski opened this issue Jun 25, 2022 · 4 comments
Assignees
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. package/tools Related to AWS CDK Tools or CLI

Comments

@jedrekdomanski
Copy link
Contributor

Describe the bug

I have multiple AWS profiles for switching between my company's and my personal profiles. I have this in my ~/.aws/config

[default]
region=eu-central-1
cli_pager=

[my-other-aws-profile]
region=us-west-2

[my-yet-other-aws-profile]
region=eu-central-1

My credentials are defined in ~/.aws/credentials

[default]
aws_access_key_id = XXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXX

[my-other-aws-profile]
aws_access_key_id = XXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXX

I used my default profile to generate my CDK stack. When I run cdk deploy I get an error message:

Unable to resolve AWS account to use. It must be either configured when you define your CDK Stack, or through the environment

When I specify --profile flag as stated in cdk --help I get the same error message.
When I add verbose logging to the command I get the following message:

Unable to determine the default AWS account: TypeError: Cannot redefine property: [my-other-aws-profile]

Expected Behavior

I am able to use specified AWS profile to deploy my CDK stack.

Current Behavior

I get an error

Unable to determine the default AWS account: TypeError: Cannot redefine property: [my-other-aws-profile]

Reproduction Steps

Generate your CDK stack using your selected profile then try to deploy it.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.28.1 (build d035432)

Framework Version

No response

Node.js Version

v18.4.0

OS

Linux Home 5.13.0-52-generic #59-Ubuntu SMP Wed Jun 15 20:17:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Language

Typescript

Language Version

No response

Other information

No response

@jedrekdomanski jedrekdomanski added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 25, 2022
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Jun 25, 2022
@alexandervandekleutab
Copy link

Does it have to do with this line cli_pager= causing parsing issues? Are you able to issue AWS CLI commands and have them resolve to the default profile?

@jedrekdomanski
Copy link
Contributor Author

Does it have to do with this line cli_pager= causing parsing issues? Are you able to issue AWS CLI commands and have them resolve to the default profile?

Of course, everything works as normal, I switch profiles multiple times a day and all works fine. 'cli_pager=' is just a way to overwrite the dafult annoying behavior that outputs everything to 'less' instead of to stdout.

@peterwoodworth
Copy link
Contributor

I'm going to close this in favor of the newer issue you've opened @jedrekdomanski

I believe it's as cory mentioned in that thread, in your config file you should only have one definition of the profile you're using, and prefix it with the word profile https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html#cli-configure-profiles-create

@rix0rrr rix0rrr closed this as completed Jul 7, 2022
@github-actions
Copy link

github-actions bot commented Jul 7, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

4 participants