mitchellh/vagrant-aws

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

ShiraazMoollatjie opened this issue · 5 comments

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:

<aws_dir>/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

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

Same here. It seems like aws.region gets ignored

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

@albertoal nothing change after using environment variable

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