Method: instances.insert

Creates an instance resource in the specified project using the data included in the request.

HTTP request

POST https://compute.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
project

string

Project ID for this request.

zone

string

The name of the zone for this request.

Query parameters

Parameters
requestId

string

An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed.

For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments.

The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).

sourceInstanceTemplate

string

Specifies instance template to create the instance.

This field is optional. It can be a full or partial URL. For example, the following are all valid URLs to an instance template:

Authorization requires the following IAM permission on the specified resource sourceInstanceTemplate:

  • compute.instanceTemplates.useReadOnly

Request body

The request body contains data with the following structure:

JSON representation
{
  "id": string,
  "creationTimestamp": string,
  "name": string,
  "description": string,
  "tags": {
    "items": [
      string
    ],
    "fingerprint": string
  },
  "machineType": string,
  "status": enum,
  "statusMessage": string,
  "zone": string,
  "canIpForward": boolean,
  "networkInterfaces": [
    {
      "network": string,
      "subnetwork": string,
      "networkIP": string,
      "ipv6Address": string,
      "name": string,
      "accessConfigs": [
        {
          "type": enum,
          "name": string,
          "natIP": string,
          "externalIpv6": string,
          "externalIpv6PrefixLength": integer,
          "setPublicPtr": boolean,
          "publicPtrDomainName": string,
          "networkTier": enum,
          "kind": string
        }
      ],
      "ipv6AccessConfigs": [
        {
          "type": enum,
          "name": string,
          "natIP": string,
          "externalIpv6": string,
          "externalIpv6PrefixLength": integer,
          "setPublicPtr": boolean,
          "publicPtrDomainName": string,
          "networkTier": enum,
          "kind": string
        }
      ],
      "aliasIpRanges": [
        {
          "ipCidrRange": string,
          "subnetworkRangeName": string
        }
      ],
      "fingerprint": string,
      "stackType": enum,
      "ipv6AccessType": enum,
      "queueCount": integer,
      "nicType": enum,
      "kind": string
    }
  ],
  "disks": [
    {
      "type": enum,
      "mode": enum,
      "source": string,
      "deviceName": string,
      "index": integer,
      "boot": boolean,
      "initializeParams": {
        "diskName": string,
        "sourceImage": string,
        "diskSizeGb": string,
        "diskType": string,
        "sourceImageEncryptionKey": {
          "rawKey": string,
          "rsaEncryptedKey": string,
          "kmsKeyName": string,
          "sha256": string,
          "kmsKeyServiceAccount": string
        },
        "labels": {
          string: string,
          ...
        },
        "sourceSnapshot": string,
        "sourceSnapshotEncryptionKey": {
          "rawKey": string,
          "rsaEncryptedKey": string,
          "kmsKeyName": string,
          "sha256": string,
          "kmsKeyServiceAccount": string
        },
        "description": string,
        "resourcePolicies": [
          string
        ],
        "onUpdateAction": enum,
        "provisionedIops": string
      },
      "autoDelete": boolean,
      "licenses": [
        string
      ],
      "interface": enum,
      "guestOsFeatures": [
        {
          "type": enum
        }
      ],
      "diskEncryptionKey": {
        "sha256": string,
        "kmsKeyServiceAccount": string,

        
        "rawKey": string,
        "rsaEncryptedKey": string,
        "kmsKeyName": string
        
      },
      "diskSizeGb": string,
      "shieldedInstanceInitialState": {
        "pk": {
          "content": string,
          "fileType": enum
        },
        "keks": [
          {
            "content": string,
            "fileType": enum
          }
        ],
        "dbs": [
          {
            "content": string,
            "fileType": enum
          }
        ],
        "dbxs": [
          {
            "content": string,
            "fileType": enum
          }
        ]
      },
      "kind": string
    }
  ],
  "metadata": {
    "fingerprint": string,
    "items": [
      {
        "key": string,
        "value": string
      }
    ],
    "kind": string
  },
  "serviceAccounts": [
    {
      "email": string,
      "scopes": [
        string
      ]
    }
  ],
  "selfLink": string,
  "scheduling": {
    "onHostMaintenance": enum,
    "automaticRestart": boolean,
    "preemptible": boolean,
    "nodeAffinities": [
      {
        "key": string,
        "operator": enum,
        "values": [
          string
        ]
      }
    ],
    "minNodeCpus": integer,
    "locationHint": string
  },
  "cpuPlatform": string,
  "labels": {
    string: string,
    ...
  },
  "labelFingerprint": string,
  "minCpuPlatform": string,
  "guestAccelerators": [
    {
      "acceleratorType": string,
      "acceleratorCount": integer
    }
  ],
  "startRestricted": boolean,
  "deletionProtection": boolean,
  "resourcePolicies": [
    string
  ],
  "reservationAffinity": {
    "consumeReservationType": enum,
    "key": string,
    "values": [
      string
    ]
  },
  "hostname": string,
  "displayDevice": {
    "enableDisplay": boolean
  },
  "shieldedInstanceConfig": {
    "enableSecureBoot": boolean,
    "enableVtpm": boolean,
    "enableIntegrityMonitoring": boolean
  },
  "shieldedInstanceIntegrityPolicy": {
    "updateAutoLearnPolicy": boolean
  },
  "confidentialInstanceConfig": {
    "enableConfidentialCompute": boolean
  },
  "fingerprint": string,
  "privateIpv6GoogleAccess": enum,
  "advancedMachineFeatures": {
    "enableNestedVirtualization": boolean,
    "threadsPerCore": integer
  },
  "lastStartTimestamp": string,
  "lastStopTimestamp": string,
  "lastSuspendedTimestamp": string,
  "satisfiesPzs": boolean,
  "kind": string
}
Fields
id

string (fixed64 format)

[Output Only] The unique identifier for the resource. This identifier is defined by the server.

creationTimestamp

string

[Output Only] Creation timestamp in RFC3339 text format.

name

string

[REQUIRED] The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

description

string

An optional description of this resource. Provide this property when you create the resource.

tags

object

Tags to apply to this instance. Tags are used to identify valid sources or targets for network firewalls and are specified by the client during instance creation. The tags can be later modified by the setTags method. Each tag within the list must comply with RFC1035. Multiple tags can be specified via the 'tags.items' field.

Authorization requires the following IAM permission on the specified resource tags:

  • compute.instances.setTags
tags.items[]

string

An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035.

tags.fingerprint

string (bytes format)

Specifies a fingerprint for this request, which is essentially a hash of the tags' contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update tags. You must always provide an up-to-date fingerprint hash in order to update or change tags.

To see the latest fingerprint, make get() request to the instance.

A base64-encoded string.

machineType

string

[REQUIRED] Full or partial URL of the machine type resource to use for this instance, in the format: zones/zone/machineTypes/machine-type. This is provided by the client when the instance is created. For example, the following is a valid partial url to a predefined machine type:

zones/us-central1-f/machineTypes/n1-standard-1

To create a custom machine type, provide a URL to a machine type in the following format, where CPUS is 1 or an even number up to 32 (2, 4, 6, ... 24, etc), and MEMORY is the total memory for this instance. Memory must be a multiple of 256 MB and must be supplied in MB (e.g. 5 GB of memory is 5120 MB):

zones/zone/machineTypes/custom-CPUS-MEMORY

For example: zones/us-central1-f/machineTypes/custom-4-5120 For a full list of restrictions, read the Specifications for custom machine types.

status

enum

[Output Only] The status of the instance. One of the following values: PROVISIONING, STAGING, RUNNING, STOPPING, SUSPENDING, SUSPENDED, REPAIRING, and TERMINATED. For more information about the status of the instance, see Instance life cycle.

statusMessage

string

[Output Only] An optional, human-readable explanation of the status.

zone

string

[Output Only] URL of the zone where the instance resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body.

canIpForward

boolean

Allows this instance to send and receive packets with non-matching destination or source IPs. This is required if you plan to use this instance to forward routes. For more information, see Enabling IP Forwarding.

networkInterfaces[]

object

An array of network configurations for this instance. These specify how interfaces ar