Want to create a VM instance in Google Cloud Platform by using CLI

Trying to create a VM instance in Google Cloud Platform. Getting error in the mentioned process. Trying to resolve it.

Error: **Could not fetch a resource:

  • Invalid value for field 'resource.networkInterfaces[0].subnetwork': 'https://compute.googleapis.com/compute/v1/projects/noted-aloe-316514/regions/us/subnetworks/'. The URL is malformed.**

Anyone, please guide me. My intention to make VM creation automated and make it simple by putting it all together in an automated Bash Script.

1 answer

  • answered 2021-06-18 16:59 Alfons Muñoz

    The error indicates that the URL is malformed. It probably because that "subnetwork" does not exist as you write it.

    One way to fix it is to have a look in the documentation to know the right way to write the command. Also be sure that that subnet exist in your GCP project.


    The easy way to avoid typos is to create the VM in the console the first time (you don't really have to create it, just start the form), at the bottom of the page you will see a line that says "Equivalent REST or command line", click in "command line" to see exactly the CLI command equivalent to the VM you are configuring. Use this command line in your CLI console or script.

    Equivalent REST or command line