0

as in title, I am trying to use Google API Explorer to run vm instance. I am using instances.insert for this, but I can't get it to work. After successfuly executing the call I can not see any newly creted vm instance in https://console.cloud.google.com/compute/instances

The request I am trying to execute is copied from Equivalent REST request in Google Cloud Console Create an instance web page :

{ "name": "some-name", "machineType": "projects/my-project-id/zones/europe-west3-c/machineTypes/f1-micro", "displayDevice": { "enableDisplay": false }, "metadata": { "items": [ { "key": "startup-script", "value": "#! /bin/bash\necho hello\nEOF" } ] }, "tags": { "items": [] }, "disks": [ { "type": "PERSISTENT", "boot": true, "mode": "READ_WRITE", "autoDelete": true, "deviceName": "some-name", "initializeParams": { "sourceImage": "projects/debian-cloud/global/images/debian-10-buster-v20200910", "diskType": "projects/my-project-id/zones/europe-west3-c/diskTypes/pd-standard", "diskSizeGb": "10", "labels": {} }, "diskEncryptionKey": {} } ], "canIpForward": false, "networkInterfaces": [ { "subnetwork": "projects/my-project-id/regions/europe-west3/subnetworks/default", "accessConfigs": [ { "name": "External NAT", "type": "ONE_TO_ONE_NAT", "networkTier": "PREMIUM" } ], "aliasIpRanges": [] } ], "description": "", "labels": {}, "scheduling": { "preemptible": false, "onHostMaintenance": "MIGRATE", "automaticRestart": true, "nodeAffinities": [] }, "deletionProtection": false, "reservationAffinity": { "consumeReservationType": "ANY_RESERVATION" }, "serviceAccounts": [ { "email": "[email protected]", "scopes": [ "https://www.googleapis.com/auth/cloud-platform" ] } ], "shieldedInstanceConfig": { "enableSecureBoot": false, "enableVtpm": true, "enableIntegrityMonitoring": true }, "confidentialInstanceConfig": { "enableConfidentialCompute": false } } 

Here is the response with status 200

{ "id": "2981010757915612255", "name": "operation-1602235056020-5b1396b5c5cee-e0e30499-4d06ce75", "zone": "https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c", "operationType": "insert", "targetLink": "https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c/instances/ams2-linux-race-1", "targetId": "1541614827291382879", "status": "RUNNING", "user": "[email protected]", "progress": 0, "insertTime": "2020-10-09T02:17:36.818-07:00", "startTime": "2020-10-09T02:17:36.821-07:00", "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c/operations/operation-1602235056020-5b1396b5c5cee-e0e30499-4d06ce75", "kind": "compute#operation" } 

I have the same issue with C# code example from https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert#examples

I can execute the same request without errors and in response I am getting this

{ "clientOperationId":null, "creationTimestamp":null, "description":null, "endTime":null, "error":null, "httpErrorMessage":null, "httpErrorStatusCode":null, "id":3283200477858999168, "insertTime":"2020-10-09T00:46:55.187-07:00", "kind":"compute#operation", "name":"operation-1602229614262-5b1382701b989-381126a6-cc145485", "operationType":"insert", "progress":0, "region":null, "selfLink":"https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c/operations/operation-1602229614262-5b1382701b989-381126a6-cc145485", "startTime":"2020-10-09T00:46:55.189-07:00", "status":"RUNNING", "statusMessage":null, "targetId":2365846324436118401, "targetLink":"https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c/instances/some-name", "user":"[email protected]", "warnings":null, "zone":"https://www.googleapis.com/compute/v1/projects/my-project-id/zones/europe-west3-c", "ETag":null } 

but I can't see any new instance beeing created...

Does any one know what is the issue here? The Compute Engine API is enabled. Result of gcloud services list:

NAME TITLE ... compute.googleapis.com Compute Engine API ... 

1 Answer 1

2

The API call to create an instance is asynchronous, you got the HTTP status 200 for the successful submission of a valid request but that doesn't mean that the instance was successfully created.

The "progress": 0 output shows it hasn't completed, after completion you would get "progress": 100. Use the gcloud compute operations describe OPERATION_NAME command to follow the status of your request. The operation name is in the output of the API call - "name": "operation-1602235056020-5b1396b5c5cee-e0e30499-4d06ce75"... that should give you the reason why the operation failed if the instance is not created. You can also use stackdriver activity logs on the GCP console for any errors related to your request.

1
  • Thank you :) while gcloud compute operations describe OPERATION_NAME gave me an error ERROR: (gcloud.compute.operations.describe) Could not fetch resource: - The resource '... was not found I was found in logs that the instances weren't created due to "ZONE_RESOURCE_POOL_EXHAUSTED", after changing the zone I was able to create vm instance. Commented Oct 12, 2020 at 6:49

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.