mitchellh / vagrant-aws

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

When configuring a`aws_dir` and `aws.region` in the same Vagrantfile, the `aws.region` value is ignored #528

Open ShiraazMoollatjie opened 6 years ago

ShiraazMoollatjie commented 6 years ago

When I configure my AWS instance, I notice that when I use aws.aws_dir and override the region with aws.region, then the region is ignored.

Files involved:

/config

[default]
region=eu-west-1
output=text

Vagrantfile

Vagrant.configure(2) do |config|
    config.vm.provider :aws do |aws, override|
        # AWS Configuration
        override.vm.box = 'dummy'

        aws.aws_dir = 'D:\\application-data\\aws\\'
        aws.associate_public_ip = true
        aws.ami = '******'
        aws.region = 'eu-west-1'
        aws.instance_type = 't2.micro'
        aws.subnet_id = 'subnet-0b076042'
        aws.tags = {
            'Name' => 'Provisioned by Vagrant'
        }

        aws.keypair_name = 'RaaS'

        override.ssh.username = 'centos'
        override.ssh.private_key_path = '*****'
    end
end

Terminal Output - note the region is different

==> default: Warning! The AWS provider doesn't support any of the Vagrant
==> default: high-level network configurations (`config.vm.network`). They
==> default: will be silently ignored.
==> default: Warning! You're launching this instance into a VPC without an
==> default: elastic IP. Please verify you're properly connected to a VPN so
==> default: you can access this machine, otherwise Vagrant will not be able
==> default: to SSH into it.
==> default: Launching an instance with the following settings...
==> default:  -- Type: t2.micro
==> default:  -- AMI: *****
==> default:  -- Region: us-east-1
==> default:  -- Keypair: RaaS
==> default:  -- Subnet ID: subnet-0b076042
==> default:  -- Block Device Mapping: []
==> default:  -- Terminate On Shutdown: false
==> default:  -- Monitoring: false
==> default:  -- EBS optimized: false
==> default:  -- Source Destination check:
==> default:  -- Assigning a public IP address in a VPC: true
==> default:  -- VPC tenancy specification: default
There was an error talking to AWS. The error message is shown
below:

Subnet ID not found: subnet-0b076042

At the moment I am using the intended region as my default region

bob2build commented 6 years ago

Facing the same issue. Even if I remove the region value from .aws/config, It tries to launch instance in us-east-1 (default) instead of picking the one which is configured

gwynnarth commented 6 years ago

Same here. It seems like aws.region gets ignored

albertoal commented 6 years ago

Same issue here. Overriding the AWS Default region using environment variables did the trick for me: $ export AWS_DEFAULT_REGION="us-west-2"

https://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html

naviat commented 5 years ago

@albertoal nothing change after using environment variable

AnujSingh28 commented 3 years ago

@ShiraazMoollatjie getting the same issue. Have you got any way out of it?