Search code examples
gogoogle-cloud-platformgoogle-compute-enginegce-instance-group

Can't define Network when creating Instance Group with Go client library?


When creating an unmanaged instance group through GCP Console, I can see the REST request as:

POST https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d/instanceGroups
{
  "name": "ig-web",
  "network": "https://www.googleapis.com/compute/v1/projects/my-project/global/networks/nomad-network",
  "namedPorts": [
    {
      "name": "http",
      "port": 11080
    }
  ]
}

However, according to the API docs and client library generated code, one has no way to set the network URL.

Anyone care to clarify?


Solution

  • It's actually a documentation bug. The following will work:

    op, err := gce.service.InstanceGroups.Insert(projectID, zone, &compute.InstanceGroup{
            Name:       name,
            NamedPorts: namedPorts,
            Network:    networkURL}).Do()