0
votes

I am trying to update my Google Compute Engine instance group using API explorer here: https://cloud.google.com/compute/docs/reference/latest/autoscalers/update?authuser=2

I want to update min and max num of replicas using this API. The body part has

{
  "autoscalingPolicy": {
    "minNumReplicas": 2,
    "maxNumReplicas": 5,
    "coolDownPeriodSec": 60,
    "cpuUtilization": {
    "utilizationTarget": 1.5
    }
  }
}

This gives error below:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "The resource 'projects/<my-proj-name>/zones/us-central1-a/autoscalers' was not found"
   }
  ],
  "code": 404,
  "message": "The resource 'projects/<my-proj-name>/zones/us-central1-a/autoscalers' was not found"
 }
}

I confirmed the autoscaler configuration for the managed instance group by clicking the tiny "Equivalent REST" link at bottom of instance group landing page.

Is there I am missing to get it working on API explorer?

1
This should be all you need to do with regards to the APIs Explorer. The 404 indicates one of your path variables (project name or zone) is wrong, but it's hard to say for sure without details. You might get better help with this specific API if you add the tag "google-compute-engine". - John

1 Answers

0
votes

Got this sorted by trying different parameters in body part.

Looks like "name" and "target" are mandatory fields to be provided under autoscaling policy. Without these, the api could not process the request and returns error.

working body formation for me:

{
  "autoscalingPolicy": {
    "coolDownPeriodSec": 60,
    "maxNumReplicas": 2,
    "minNumReplicas": 1
  },
  "name": "<my-autoscaler-name>",
  "target": "https://www.googleapis.com/compute/v1/projects/<my-project-name>/zones/us-central1-a/instanceGroupManagers/<my-instancegroup-name>"
}

Note: that the target and name values are picked from the page that shows up by clicking the tiny "Equivalent REST" link at bottom of instance group landing page. As an observation, both strings are same for new instance groups in my case.