1

I'm attempting to create a compute.v1.instanceTemplate with the Deployment Manager (v2), but I'm getting the following error:

Unexpected response from resource of type compute.v1.instanceTemplate: 400 {statusMessage=Bad Request, errors=[{message=Invalid value for field 'resource.properties': ''.  Instance Templates must provide instance properties., domain=global, reason=invalid}]}

I suppose it's complaining about a missing property, but I can't for the life of me figure out which one that might be. I've taken a look at the InstanceTemplates resource and the advanced deployment examples, and I don't seem to be missing anything. I would be happy to be proven wrong, though.

Here's the complete resource acquired with gcloud deployment-manager deployments describe --log-http name:

{
 "id": "redacted",
 "insertTime": "2015-10-03T05:13:33.325-07:00",
 "updateTime": "2015-10-03T05:42:50.152-07:00",
 "name": "tpl-redacted",
 "type": "compute.v1.instanceTemplate",
 "update": {
  "manifest": "https://www.googleapis.com/deploymentmanager/v2/projects/project-redacted/global/deployments/redacted/manifests/manifest-redacted",
  "error": {
   "errors": [
    {
     "code": "RESOURCE_ERROR",
     "location": "redacted/tpl-redacted",
     "message": "Unexpected response from resource of type compute.v1.instanceTemplate: 400 {statusMessage=Bad Request, errors=[{message=Invalid value for field 'resource.properties': ''.  Instance Templates must provide instance properties., domain=global, reason=invalid}]}"
    }
   ]
  },
  "state": "FAILED",
  "intent": "CREATE_OR_ACQUIRE",
  "properties": "canIpForward: true\ndisks:\n- autoDelete: true\n  boot: true\n  deviceName: boot\n  initializeParams:\n    diskSizeGb: 10\n    diskType: pd-standard\n    sourceImage: https://www.googleapis.com/compute/v1/projects/project-redacted/global/images/redacted-image\n  mode: READ_WRITE\n  type: PERSISTENT\nmachineType: https://www.googleapis.com/compute/v1/projects/project-redacted/zones/asia-east1-c/machineTypes/g1-small\nnetworkInterfaces:\n- accessConfigs: []\n  network: $(ref.nw-redacted.selfLink)\nscheduling:\n  automaticRestart: true\n  onHostMaintenance: MIGRATE\nserviceAccounts:\n- scopes:\n  - storage-ro\ntags:\n  items:\n  - redacted\nzone: asia-east1-c\n",
  "finalProperties": "canIpForward: true\ndisks:\n- autoDelete: true\n  boot: true\n  deviceName: boot\n  initializeParams:\n    diskSizeGb: 10\n    diskType: pd-standard\n    sourceImage: https://www.googleapis.com/compute/v1/projects/project-redacted/global/images/redacted-image\n  mode: READ_WRITE\n  type: PERSISTENT\nmachineType: https://www.googleapis.com/compute/v1/projects/project-redacted/zones/asia-east1-c/machineTypes/g1-small\nnetworkInterfaces:\n- accessConfigs: []\n  network: https://www.googleapis.com/compute/v1/projects/project-redacted/global/networks/nw-redacted\nscheduling:\n  automaticRestart: true\n  onHostMaintenance: MIGRATE\nserviceAccounts:\n- scopes:\n  - storage-ro\ntags:\n  items:\n  - redacted\nzone: asia-east1-c\n"
 }
}

And here's a human-friendlier version of finalProperties:

canIpForward: true
disks:
- autoDelete: true
  boot: true
  deviceName: boot
  initializeParams:
    diskSizeGb: 10
    diskType: pd-standard
    sourceImage: https://www.googleapis.com/compute/v1/projects/project-redacted/global/images/redacted-image
  mode: READ_WRITE
  type: PERSISTENT
machineType: https://www.googleapis.com/compute/v1/projects/project-redacted/zones/asia-east1-c/machineTypes/g1-small
networkInterfaces:
- accessConfigs: []
  network: https://www.googleapis.com/compute/v1/projects/project-redacted/global/networks/nw-redacted
scheduling:
  automaticRestart: true
  onHostMaintenance: MIGRATE
serviceAccounts:
- scopes:
  - storage-ro
tags:
  items:
  - redacted
zone: asia-east1-c

Any ideas? Alternatively, examples of successful compute.v1.instanceTemplate deployments would be greatly appreciated.

3

Turns out one of the advanced deployment examples did indeed have an example of compute.v1.instanceTemplate usage. Instead of a zone, the resource should specify a project instead, which makes more sense indeed, although it doesn't seem to be documented anywhere except in that one example. Less sensibly, though, the actual instanceTemplate parameters are placed inside another properties object. Not sure where this is coming from, but here's my final working jinja template (note that some fields are using their default values and could actually be left out):

resources:
  - name: {{ env["name"] }}
    type: compute.v1.instanceTemplate
    properties:
      project: {{ env["project"] }}
      properties:
        machineType: {{ properties["machineType"] }}
        canIpForward: true
        scheduling:
          automaticRestart: true
          onHostMaintenance: MIGRATE
          preemptible: false
        tags:
          items:
            - redacted
        disks:
          - deviceName: boot
            boot: true
            autoDelete: true
            mode: READ_WRITE
            type: PERSISTENT
            initializeParams:
              diskSizeGb: 10
              diskType: pd-standard
              sourceImage: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/global/images/redacted
        networkInterfaces:
          - network: $(ref.{{ properties["network"] }}.selfLink)
        serviceAccounts:
          - email: default
            scopes:
              - https://www.googleapis.com/auth/devstorage.read_only

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.