1

I want to create a compute engine from a instance-template using the gcloud CLI. I have created a instance template named it-collector-server. When I try to create a server with the instance template I get a error: The resource 'projects/s-dev/global/instanceTemplates/it-collector-server' was not found. What causes this error and how can I fix it?

I have one instance template:

gcloud compute instance-templates list

NAME                 MACHINE_TYPE  PREEMPTIBLE  CREATION_TIMESTAMP
it-collector-server  e2-medium                  2024-04-30T03:01:14.759-07:00

This is the full information about the template:

gcloud compute instance-templates list --format=json

gcloud compute instance-templates list --format=json
[
  {
    "creationTimestamp": "2024-04-30T03:01:14.759-07:00",
    "description": "",
    "id": "12345",
    "kind": "compute#instanceTemplate",
    "name": "it-collector-server",
    "properties": {
      "canIpForward": false,
      "confidentialInstanceConfig": {
        "enableConfidentialCompute": false
      },
      "description": "",
      "disks": [
        {
          "autoDelete": true,
          "boot": true,
          "deviceName": "it-collector-server",
          "index": 0,
          "initializeParams": {
            "diskSizeGb": "10",
            "diskType": "pd-balanced",
            "sourceImage": "projects/ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20240426"
          },
          "kind": "compute#attachedDisk",
          "mode": "READ_WRITE",
          "type": "PERSISTENT"
        }
      ],
      "keyRevocationActionType": "NONE",
      "machineType": "e2-medium",
      "metadata": {
        "fingerprint": "i9go6u23i84=",
        "kind": "compute#metadata"
      },
      "networkInterfaces": [
        {
          "accessConfigs": [
            {
              "kind": "compute#accessConfig",
              "name": "External NAT",
              "networkTier": "PREMIUM",
              "type": "ONE_TO_ONE_NAT"
            }
          ],
          "kind": "compute#networkInterface",
          "name": "nic0",
          "network": "https://www.googleapis.com/compute/v1/projects/s-dev/global/networks/default",
          "stackType": "IPV4_ONLY"
        }
      ],
      "reservationAffinity": {
        "consumeReservationType": "ANY_RESERVATION"
      },
      "scheduling": {
        "automaticRestart": true,
        "onHostMaintenance": "MIGRATE",
        "preemptible": false,
        "provisioningModel": "STANDARD"
      },
      "serviceAccounts": [
        {
          "email": "[email protected]",
          "scopes": [
            "https://www.googleapis.com/auth/devstorage.read_only",
            "https://www.googleapis.com/auth/logging.write",
            "https://www.googleapis.com/auth/monitoring.write",
            "https://www.googleapis.com/auth/servicecontrol",
            "https://www.googleapis.com/auth/service.management.readonly",
            "https://www.googleapis.com/auth/trace.append"
          ]
        }
      ],
      "shieldedInstanceConfig": {
        "enableIntegrityMonitoring": true,
        "enableSecureBoot": false,
        "enableVtpm": true
      },
      "tags": {}
    },
    "region": "https://www.googleapis.com/compute/v1/projects/s-dev/regions/europe-north1",
    "selfLink": "https://www.googleapis.com/compute/v1/projects/s-dev/regions/europe-north1/instanceTemplates/it-collector-server"
  }
]

Now I want to create a compute engine using the instance template:

gcloud compute instances create my-test-vm --source-instance-template=it-collector-server

ERROR: (gcloud.compute.instances.create) Could not fetch resource:
 - The resource 'projects/s-dev/global/instanceTemplates/it-collector-server' was not found

1 Answer 1

0

MY_TEMPLATE=$(echo $(gcloud compute instance-templates list --format="value(selfLink)"))
gcloud compute instances create my-test-vm --source-instance-template="$MY_TEMPLATE"
or
gcloud compute instances create my-test-vm --zone="europe-north1-a" --source-instance-template="$MY_TEMPLATE"

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.