mitchellh / vagrant-aws

Use Vagrant to manage your EC2 and VPC instances.
MIT License
2.61k stars 574 forks source link

Secret AWS values are not read from config #470

Open ephracis opened 8 years ago

ephracis commented 8 years ago

Here's my AWS config file:

$ cat $HOME/.aws/config 
[default]
output = table
region = eu-central-1
aws_access_key_id = <REDACTED>
aws_secret_access_key = <REDACTED>

Here's my Vagrantfile:

Vagrant.configure('2') do |config|
  config.vm.box = 'dummy'

  config.vm.provider :aws do |aws, override|
    aws.keypair_name = 'themisto'
    aws.region = 'eu-central-1'
    aws.instance_type = 't2.micro'
    aws.security_groups = ['vagrant']
    aws.ami = 'ami-f9e30f96' # Ubuntu 16.04, EU (Frankfurt), hvm:instance-store

    override.ssh.username = 'ubuntu'
    override.ssh.private_key_path = '~/.ssh/id_rsa'
  end

  config.vm.provision 'chef_client' do |chef|
    chef.node_name = 'dev-web'
    chef.chef_server_url = 'https://api.chef.io/organizations/simplare'
    chef.validation_key_path = '.chef/simplare-validator.pem'
    chef.validation_client_name = 'simplare-validator'
    chef.add_recipe 'simplare-base'
    # chef.add_role 'web'
    # chef.environment = 'development'
    chef.delete_node = true
    chef.delete_client = true
  end
end

According to the README:

Note: if you don't configure aws.access_key_id or aws_secret_access_key it will attempt to read credentials from environment variables first and then from $HOME/.aws/.

But...

$ vagrant up
There are errors in the configuration of this machine. Please fix
the following errors and try again:

AWS Provider:
* An access key ID must be specified via "access_key_id"
* A secret access key is required via "secret_access_key"

Same error when I set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Seems that the Vagrantfile MUST contain the two parameters, contrary to what the README specifies.

Some info:

$ vagrant plugin list
vagrant-aws (0.7.0)
vagrant-share (1.1.5, system)

$ vagrant --version
Vagrant 1.8.1

$ ruby --version
ruby 2.3.0p7 (2016-01-21 revision 53608) [x86_64-darwin15]
asebastian-r7 commented 8 years ago

This is because you are using version 0.7.0, released prior to the changes which enabled the credentials chain. Those are in master and unreleased.

@rtyler can we get a new release? Last release was January 4th and there are some nice improvements we can be using. Are you still a maintainer?

kenorb commented 8 years ago

Fixed in PR #441, duplicated of: #151