cli: support AWS_PROFILE environment variable for using named profiles
See original GitHub issue- 🪲 bug report
-
What is the current behavior? CDK doesn’t use exported AWS_PROFILE
cdk deploy Unable to resolve AWS account to use. It must be either configured when you define your CDK or through the environment
-
What is the expected behavior (or behavior of feature suggested)?
export AWS_PROFILE=test
cdk deploy should read profile from AWS_PROFILE and deploy the template
-
What is the motivation / use case for changing the behavior or adding this feature? It should work using same env variables as AWS CLI
-
Please tell us about your environment:
- CDK CLI Version1.1.0 (build 1a11e96)
- Module Version: xx.xx.xx
- OS: Manjaro Linux
- Language: all
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Environment variables to configure the AWS CLI
Environment variables provide another way to specify configuration options and credentials, and can be useful for scripting or temporarily setting a named ......
Read more >Named profiles for the AWS CLI - AWS Command Line Interface
A named profile is a collection of settings and credentials that you can apply to a AWS CLI command. When you specify a...
Read more >Using the AWS_PROFILE Environment Variable to Choose a ...
The SDK currently looks for a profile named “default” when retrieving credentials and region settings. After this change is released, users will ...
Read more >AWS CLI Configuration Variables - AWS Documentation
When you specify a profile, either using --profile profile-name or by setting a value for the AWS_PROFILE environment variable, profile name you provide...
Read more >Environment variables support - AWS SDKs and Tools
Environment variables provide another way to specify configuration options and credentials, and can be useful for scripting or temporarily setting a named ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not worth reopening I guess, but to help any future travellers that wind up here:
I recently encountered this on a fresh install using credential helpers: CDK did not respect
$AWS_PROFILE
even when it was definitely available in the environment (env
), exported, and even visible to node (node
,process.env.AWS_PROFILE
).…But the problem magically fixed after I created a blank credentials file:
touch ~/.aws/credentials
. Now cdk is automatically using my selected AWS_PROFILE.So if you’re in a context where you don’t have a credentials file created because you don’t really use one - maybe give this a try!
Not sure if this help, but in my organisation we use AWS SSO, with over 90 AWS Accounts, with MFA, so it was impossible to manage CDK without AWS CLIv2 with profiles, and AWS SSO support.
I found a way to solve it, so till its officially released, you can use this, it works quite all right: MatsCloud blog - CDK with AWS SSO multi account multi profile