aws / aws-toolkit-jetbrains

AWS Toolkit for JetBrains - a plugin for interacting with AWS from JetBrains IDEs
https://plugins.jetbrains.com/plugin/11349-aws-toolkit
Apache License 2.0
744 stars 213 forks source link

Use $AWS_CREDENTIAL_FILE, if set, to find config file location #3610

Open andrewtcymmer opened 1 year ago

andrewtcymmer commented 1 year ago

Describe the bug The AWS Toolkit plugin on DataGrip is not respecting custom location of AWS credentials files. My AWS CLI is configured with $AWS_CREDENTIAL_FILE set to a non-default location, which seems to cause the JetBrains AWS Toolkit plugin to think that I do not have a credentials file. See attached screenshot C below.

Since the AWS CLI supports custom credential file locations (see here), I expect the AWS Toolkit plugin to respect them also. I have set up my CLI this way, and it works as expected.

As a developer, I use both the CLI and the JetBrains Toolkit plugin daily. I would like both my CLI and Toolkit plugin to use the same single configuration, and I want to be able to organize my many config files according to the XDG specification for parity between my OSX and Linux work environments.

To reproduce I have a default install of zsh on OSX Ventura 13.3.1, Apple Silicon M2 chip for this scenario.

  1. Set environment variables in $HOME/.zshenv according to the AWS CLI specification (link)
    • AWS_CONFIG_FILE=$HOME/.config/aws/config
    • AWS_CREDENTIALS_FILE=$HOME/.config/aws/credentials
  2. Set up default profile with an access key.
  3. Restart terminal. Run a CLI command, see that configuration is working as expected.
  4. Fresh install of DataGrip.
  5. Install AWS Toolkit plugin.
  6. Restart DataGrip.
  7. Set up a new Postgres connection.
    • Authentication: "AWS IAM"
    • No other fields ought to be necessary to reproduce this bug.
  8. "Credentials" drop list is empty (see Screenshot A below). This is the error. I expected to have all my profiles which I have set up in $HOME/.config/aws/credentials

Expected behavior In last step above, I expect all the profiles specified in my AWS credentials file to show in this list. My AWS credentials file is located at $HOME/.config/aws/config, and this location is set via environment variable $AWS_CREDENTIAL_FILE.

Screenshots

Screenshot A My datasource configuration, showing the empty listing of AWS Profiles. Screenshot 2023-04-18 at 4 58 35 PM

Screenshot B Accessing the AWS Profile selector in lower-right of DataGrip. Screenshot 2023-04-18 at 5 06 32 PM

Screenshot C Trying to access AWS Profile through selector (see previous screenshot) I get asked to create a file. I do not want this, I already have a credential file located with $AWS_CREDENTIAL_FILE env var. Screenshot 2023-04-18 at 5 06 51 PM

Screenshot D Use of AWS_CONFIG_FILE and AWS_CREDENTIAL_FILE env vars. My CLI works perfectly with these, and no file in default location. Screenshot 2023-04-18 at 5 07 31 PM

Your Environment

Additional context I have been using DataGrip and the AWS Toolkit plugin for years without any issues, yet I had the AWS credential file in the default location. However I was recently given a new MacBook M2 for work, which forced me to re-set-up a machine.

rli commented 1 year ago

We use the AWS Java SDK to resolve the config/credentials files (and the SDK definitely respects the env vars), but what's probably happening is that on Mac, applications do not inherit your shell environment and so the toolkit is not aware of your configuration.

I think we might be able to fix this

In the meantime, the toolkit will respect config/credential related Java properties defined in Help -> Edit Custom Properties... (requires IDE restart)

image

rli commented 1 year ago

Related: #1860

andrewtcymmer commented 1 year ago

In the meantime, the toolkit will respect config/credential related Java properties defined in Help -> Edit Custom Properties... (requires IDE restart)

Thank you for the quick reply. This suggestion to add the two lines as shown to the properties file is working well for me.