1
votes

I am having trouble figuring out the problem with the API hit to create a Google virtual machine through Google Compute Engine API.

URL: https://cloud.google.com/compute/docs/reference/latest/instances/insert?apix=true#examples

My request data is:

{
  "machineType": "zones/us-central1-c/machineTypes/f1-micro",
  "name": "api-test",
  "networkInterfaces": [
    {
      "accessConfigs": [
        {
          "type": "ONE_TO_ONE_NAT",
          "name": "External NAT"
        }
      ],
      "network": "global/networks/default"
    }
  ],
  "disks": [
    {
      "boot": true,
      "autoDelete": true,
      "type": "SCRATCH"
    }
  ]
}

and I am getting output:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "backendError",
    "message": "Code: '55C355EC47648.A8E5D85.FA0DAF10'"
   }
  ],
  "code": 503,
  "message": "Code: '55C355EC47648.A8E5D85.FA0DAF10'"
 }
}

Doesn't give me any reason for the error. Same issue is when I hit the API using Ruby Library. Authentication is fine as I can do various other stuff like getting the images and running instances data. Please help me out.

1

1 Answers

0
votes

Figured out the problem. We have to use the disks type as "PERSISTENT" rather than "SCRATCH" and specify the disks["initializeParams"]["sourceImage"] as an existing image from https://console.cloud.google.com/compute/images and then use it like this in the request body of your request:

{
    "name": "api-test3",
    "machineType": "zones/us-central1-c/machineTypes/f1-micro",
    "networkInterfaces": [
        {
            "accessConfigs": [
                {
                    "type": "ONE_TO_ONE_NAT",
                    "name": "External NAT"
                }
            ],
            "network": "global/networks/default"
        }
    ],
    "disks": [
        {
            "boot": "true",
            "type": "PERSISTENT",
            "autoDelete": "true",
            "initializeParams": [
                {
                    "sourceImage": "global/images/ubuntu-1404-lts"
                }
            ]
        }
    ]
}