Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating VM instance in Google Compute Engine

I am trying to follow a tutorial that came up on the google cloud platform console for creating a MongoDB application using Compute Engine. I follow the tutorial for creating the VMs but they are not created and return the following error:

Invalid value for field 'resource.networkInterfaces[0].network': ''. The referenced network resource cannot be found.

Any idea what this could be? I have not created any VMs previously so am unsure what this is. I am not using commandline, I am using the console to do this.

like image 560
Jim Avatar asked Jun 13 '16 20:06

Jim


2 Answers

I just experienced the same thing trying to create a VM on a fresh project. It looks like Google is having problems provisioning new projects (at least the compute engine networking stuff).

You'll have to manually create the default network. Here's how to do that:

Activate the Google Cloud Shell (button in upper right of Cloud Console website), then run these commands:

gcloud compute networks create default
gcloud compute firewall-rules create default-allow-icmp --network default --allow icmp --source-ranges 0.0.0.0/0
gcloud compute firewall-rules create default-allow-ssh --network default --allow tcp:22 --source-ranges 0.0.0.0/0
gcloud compute firewall-rules create default-allow-internal --network default --allow tcp:0-65535,udp:0-65535,icmp --source-ranges 10.128.0.0/9

After that, you should be able to create VMs.

Another option would be to complain to Google.. This is not normal behavior.

like image 187
Ray Pitmon Avatar answered Sep 19 '22 10:09

Ray Pitmon


Terraform, Juju and etc will give you an error:

Error 400: Invalid value for field 'resource.networkInterfaces[0]': ''. Subnetwork should be specified for custom subnetmode network, invalid

The actual issue is subnet-mode

Google Documentation:

https://cloud.google.com/sdk/gcloud/reference/compute/networks/create

gcloud compute networks create NAME --subnet-mode=MODE

--subnet-mode=MODE The subnet mode of the network. If not specified, defaults to AUTO. MODE must be one of:

auto - Subnets are created automatically. This is the recommended selection.

custom - Create subnets manually.

https://cloud.google.com/sdk/gcloud/reference/compute/networks/list

To check subnet modes use: gcloud compute networks list

NAME            SUBNET_MODE  BGP_ROUTING_MODE  IPV4_RANGE  GATEWAY_IPV4
default         AUTO         REGIONAL
vpc-01          CUSTOM       GLOBAL
vpc-02          CUSTOM       GLOBAL
vpc-03          CUSTOM       GLOBAL

Only if you have mode "AUTO" this will solve the issue, thanks to @Ray Pitmon

like image 35
kgimpel Avatar answered Sep 18 '22 10:09

kgimpel