aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.51k stars 4.12k forks source link

[feat] Use `credentials_file` variable in config file #8958

Open lonix1 opened 1 week ago

lonix1 commented 1 week ago

Describe the feature

I want to keep user secrets separate from config.

Secrets file at custom path /home/me/.secrets/aws/credentials:

[default]
aws_access_key_id=foo
aws_secret_access_key=bar

Config file at default path /home/me/.aws/config:

[default]
region=us-east-1
credentials_file=/home/me/.secrets/aws/credentials

I assumed I can use credentials_file as it's in the docs. However that doesn't work:

Unable to locate credentials. You can configure credentials by running "aws configure".

Please let us use credentials_file as a variable in the config file.

Use Case

Proposed Solution

No response

Other Information

No response

Acknowledgements

CLI version used

2.18.1

Environment details (OS name and version, etc.)

ubuntu 22.04

tim-finnigan commented 1 week ago

Thanks for reaching out. There's not a "Config Entry" for credentials_file in the table you referenced, so the current behavior is expected.

As an alternative, have you tried setting the environment variable AWS_SHARED_CREDENTIALS_FILE? (For more information on setting environment variables for the AWS CLI please refer to this documentation: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html)

lonix1 commented 1 week ago

Yes I tried that with the env var, and it works, thanks. That's a decent workaround, though must be set every time before using the cli, or added to the shell config (bashrc or whatever).

If possible someday, it would be nicer/cleaner to use the variable from inside the config file.

tim-finnigan commented 1 week ago

Thanks for following up and confirming. I think we can continue tracking this feature request for further review.