Closed alexconst closed 8 years ago
Thanks for the work getting this started. We've been looking for something like this as well.
Two things:
AWS_SHARED_CREDENTIALS_FILE
and AWS_CONFIG_FILE
environmental variables before defaulting to ~/.aws/credentials
or ~/.aws/config
.@ThatGerber I've implemented 1) and 2). Let me know if it works for you.
Updated description: This PR reads AWS config and credentials. Behaviour aims to mimic what is described in AWS documentation: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html http://docs.aws.amazon.com/cli/latest/topic/config-vars.html Which is the following (stopping at the first successful case): 1) read config and credentials from environment variables 2) read config and credentials from files at location defined by environment variables 3) read config and credentials from files at default location
The mandatory fields for a successful "get credentials" are the id and the secret keys. Region is not required since Config#finalize falls back to sensible defaults. The behaviour is all-or-nothing (ie: no mixing between vars and files).
It also allows choosing a profile (by default it's [default]) and an "info" directory (by default $HOME/.aws), which can be specified in the Vagrantfile. Supported information: region, aws_access_key_id, aws_secret_access_key, and aws_session_token.
@rtyler Any chance for this and the other PRs to get some love?
@mitchellh is anyone actively maintaining this project?
@mitchellh don't understand why packer is reading ~/.aws/credentials but vagrant-aws is not. Please look into merging
@rtyler I believe I fixed the gemspec issue.
@rtyler any updates on this?
If possible, I'd love to see a new gem released that includes this change.
I have this error after applying this PR:
$ vagrant up --provider=aws
~/.vagrant.d/gems/gems/vagrant-aws-0.7.0/lib/vagrant-aws/config.rb:537:in `read_aws_files': undefined method `[]' for nil:NilClass (NoMethodError)
from ~/.vagrant.d/gems/gems/vagrant-aws-0.7.0/lib/vagrant-aws/config.rb:513:in `get_aws_info'
from ~/.vagrant.d/gems/gems/vagrant-aws-0.7.0/lib/vagrant-aws/config.rb:326:in `finalize!'
My config file is like:
[default]
region = us-east-1
output = text
[testing]
region = us-east-1
output = text
What's wrong?
@kenorb You are configuring your profiles incorrectly, that's why it's not working.
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles
The method is that config files should have [profile NAME]. Credentials files are set up as [NAME].
When either access_key_id or secret_access_key are not set it will attempt to read from environment variables, if those are empty then it will attempt to read from config and credentials. It allows choosing a profile (by default it's "default") and an "info" directory (by default $HOME/.aws). Supported information: region, aws_access_key_id, aws_secret_access_key and aws_session_token.
Closes issue #151