trying to launch an instance in Google Cloud using google-api-client
0.9.2
So I'm running:
compute.insert_instance(project, zone, instance_opts)
Where instance_opts
is:
---
machineType: https://www.googleapis.com/compute/v1/projects/openshift-gce-devel/zones/us-central1-a/machineTypes/n1-standard-1
disks:
- initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/myproject/global/images/myimage
type: SCRATCH
networkInterfaces:
- network: projects/myproject/global/networks/default
accessConfigs:
- name: external
name: mytest
But I'm getting an error from server:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required field 'resource.name' not specified"
}
],
"code": 400,
"message": "Required field 'resource.name' not specified"
}
}
I'm getting exact same issue even if I make instance_opts
only:
{"name": "mytest"}
I get an error for unknown field "resource" or "resource.name" if I try to set these in instance_opts
. Setting name of disk also doesn't help. So I'm wondering what the issue could be.
Huh, might be stupid but I couldn't understand it for a good time that I actually have to create an Instance
object and use it for the call.
io = Google::Apis::ComputeV1::Instance.new(instance_opts)
compute.insert_instance(project, zone, io)
But with one more detail. Hash should be :machine_type
instead of "machineType"
. That's the same for all hash keys.