0

I'm trying to use Apps Script to interact with google compute engine and generate an instance. I've tested out a payload in the "TRY IT" (on the right side) of the google page (https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert).

I'm able to generate a viable payload, but the instance created does not allow me to access the instance via clicking the "SSH" button the google console, stating that there's no external IP associated with said instance. However, when I generate an instance manually, I'm able to do this.

Is there a method to apply an ephemeral external IP through the api? Below is the json I provided in the "TRY IT" section:

{
  "machineType": "zones/ZONEUSED/machineTypes/e2-micro",
  "name": "TESTINSTANCE",
  "disks": [
    {
      "type": "PERSISTENT",
      "source": "https://www.googleapis.com/compute/v1/projects/PROJECTNAME/zones/ZONEUSED/disks/test-boot",
      "boot": true,
      "autoDelete": false
    }
  ],
  "networkInterfaces": [
    {
      "network": "global/networks/default"
    }
  ],
  "metadata": {
    "items": [
      {
        "key": "startup-script",
        "value": "touch test.txt"
      }
    ]
  },
  "serviceAccounts": [
    {
      "email": "VALID SERVICE ACCOUNT"
    }
  ]
}
Amomynous
  • 95
  • 1
  • 2
  • 7

1 Answers1

0

My solution to this was to add "accessconfigs" to networkInterfaces and set networkTier to PREMIUM.

Amomynous
  • 95
  • 1
  • 2
  • 7