mitchellh / vagrant-aws

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

aws.region is being ignored #532

Open memoryleak opened 6 years ago

memoryleak commented 6 years ago

Versions Vagrant 2.0.2 vagrant-aws (0.7.2)

Vagrantfile

config.vm.box = "dummy"
    config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
    config.vm.provider :aws do |aws, override|
    aws.keypair_name = "...."
    aws.ami = "ami-192a9460"
    aws.instance_type = "c5.large"
    aws.region = "eu-west-1"

    aws.security_groups = ["sg-....", "sg-...."]
    aws.subnet_id = "subnet-...."
    aws.iam_instance_profile_name = "EC2ReadOnly"

    override.ssh.username = "centos"
    override.ssh.private_key_path = "~/.ssh/id_rsa"
  end

Expected: AWS provider using eu-west-1 as region.

Actual: Region us-east-1 always used

sammerry commented 6 years ago

running into this same problem running vagrant on ubuntu 16.04

Vagrant (2.0.4) vagrant-aws (0.7.2)

HarryWeppner commented 6 years ago

Same here - appears env variable AWS_DEFAULT_REGION can be used as a workaround in the interim.

matttrach commented 5 years ago

Same problem here, I would prefer to avoid overriding in environment variables because it is not easy to tell what the behavior will be. Shouldn't the config region option override the aws config file?

sanjeevgopal commented 5 years ago

Is this really still open? I couldn't do a multi-region deployment due to this same reason.

chrisgavin commented 4 years ago

It looks like the problem is if you don't specify an access key or secret key explicitly, the plugin will fetch them from your environment. When doing this, it unfortunately also seems to take the liberty of setting your region as well.

https://github.com/mitchellh/vagrant-aws/blob/master/lib/vagrant-aws/config.rb#L330