question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
athewseycommented, Dec 10, 2021

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!

1reaction
mateja82commented, Jun 25, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found