mitchellh/vagrant-google

Can't Launch Vagrant VM on a Shared Subnet

dgarstang opened this issue · 1 comments

I have this Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "google/gce"
  config.vm.provider :google do |google, override|
    google.google_project_id = "corp-user-dgarstang"
    google.google_json_key_location = "~/Downloads/corp-user-dgarstang.json"
    google.image_family = "centos-7"
    google.subnetwork = "default-us-west1"
    #google.subnetwork = "https://www.googleapis.com/compute/v1/projects/corp-vpc-sandbox/regions/us-west1/subnetworks/default-us-west1"
    #google.network = "default"
    google.zone = "us-west1-a"
    google.network_project_id = "corp-vpc-sandbox"
    google.tags = ["egress-web"]
    #google.image_project_id = "corp-user-dgarstang"
    override.ssh.username = "dgarstang"
    override.ssh.private_key_path = "~/.ssh/id_rsa"
  end
end

and vagrant responds with:

/Users/dgarstang/.vagrant.d/gems/2.4.4/gems/google-api-client-0.23.9/lib/google/apis/core/http_command.rb:218:in `check_status': invalid: Invalid value for field 'resource.networkInterfaces[0].subnetwork': 'default-us-west1'. The URL is malformed. (Google::Apis::ClientError)

It doesn't even make it to the API. If I set google.subnetwork to 'default-us-west1' then the Google API responds with:

/Users/dgarstang/.vagrant.d/gems/2.4.4/gems/google-api-client-0.23.9/lib/google/apis/core/http_command.rb:218:in `check_status': invalid: Invalid value for field 'resource.networkInterfaces[0].network': 'global/networks/default'. The referenced network resource cannot be found. (Google::Apis::ClientError)

I'm trying to put the vagrant vm on a subnet shared from the corp-vpc-sandbox project. The same configuration works with other tools like Terraform and packer. There's no examples I can find of doing this.

Vagrant google plugin version is 2.4.0.

Doug

Thanks for reporting this!

Can you give me a small hint on how to reproduce this? I want to make sure that my setup is close to what you're doing. Just giving a general idea of how networks are shared between projects should be enough.