instances
Creates, updates, deletes, gets or lists a instances
resource.
Overview
Name | instances |
Type | Resource |
Id | google.compute.instances |
Fields
Name | Datatype | Description |
---|---|---|
id | string | [Output Only] The unique identifier for the resource. This identifier is defined by the server. |
name | string | 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. |
advancedMachineFeatures | object | Specifies options for controlling advanced machine features. Options that would traditionally be configured in a BIOS belong here. Features that require operating system support may have corresponding entries in the GuestOsFeatures of an Image (e.g., whether or not the OS in the Image supports nested virtualization being enabled or disabled). |
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 . |
confidentialInstanceConfig | object | A set of Confidential Instance options. |
cpuPlatform | string | [Output Only] The CPU platform used by this instance. |
creationTimestamp | string | [Output Only] Creation timestamp in RFC3339 text format. |
deletionProtection | boolean | Whether the resource should be protected against deletion. |
disks | array | Array of disks associated with this instance. Persistent disks must be created before you can assign them. |
displayDevice | object | A set of Display Device options |
fingerprint | string | Specifies a fingerprint for this resource, which is essentially a hash of the instance's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update the instance. You must always provide an up-to-date fingerprint hash in order to update the instance. To see the latest fingerprint, make get() request to the instance. |
guestAccelerators | array | A list of the type and count of accelerator cards attached to the instance. |
hostname | string | Specifies the hostname of the instance. The specified hostname must be RFC1035 compliant. If hostname is not specified, the default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal when using the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal when using zonal DNS. |
instanceEncryptionKey | object | |
keyRevocationActionType | string | KeyRevocationActionType of the instance. Supported options are "STOP" and "NONE". The default value is "NONE" if it is not specified. |
kind | string | [Output Only] Type of the resource. Always compute#instance for instances. |
labelFingerprint | string | A fingerprint for this request, which is essentially a hash of the label's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels. To see the latest fingerprint, make get() request to the instance. |
labels | object | Labels to apply to this instance. These can be later modified by the setLabels method. |
lastStartTimestamp | string | [Output Only] Last start timestamp in RFC3339 text format. |
lastStopTimestamp | string | [Output Only] Last stop timestamp in RFC3339 text format. |
lastSuspendedTimestamp | string | [Output Only] Last suspended timestamp in RFC3339 text format. |
machineType | string | 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. |
metadata | object | A metadata key/value entry. |
minCpuPlatform | string | Specifies a minimum CPU platform for the VM instance. Applicable values are the friendly names of CPU platforms, such as minCpuPlatform: "Intel Haswell" or minCpuPlatform: "Intel Sandy Bridge". |
networkInterfaces | array | An array of network configurations for this instance. These specify how interfaces are configured to interact with other network services, such as connecting to the internet. Multiple interfaces are supported per instance. |
networkPerformanceConfig | object | |
params | object | Additional instance params. |
privateIpv6GoogleAccess | string | The private IPv6 google access type for the VM. If not specified, use INHERIT_FROM_SUBNETWORK as default. |
reservationAffinity | object | Specifies the reservations that this instance can consume from. |
resourcePolicies | array | Resource policies applied to this instance. |
resourceStatus | object | Contains output only fields. Use this sub-message for actual values set on Instance attributes as compared to the value requested by the user (intent) in their instance CRUD calls. |
satisfiesPzi | boolean | [Output Only] Reserved for future use. |
satisfiesPzs | boolean | [Output Only] Reserved for future use. |
scheduling | object | Sets the scheduling options for an Instance. |
selfLink | string | [Output Only] Server-defined URL for this resource. |
serviceAccounts | array | A list of service accounts, with their specified scopes, authorized for this instance. Only one service account per VM instance is supported. Service accounts generate access tokens that can be accessed through the metadata server and used to authenticate applications on the instance. See Service Accounts for more information. |
shieldedInstanceConfig | object | A set of Shielded Instance options. |
shieldedInstanceIntegrityPolicy | object | The policy describes the baseline against which Instance boot integrity is measured. |
sourceMachineImage | string | Source machine image |
sourceMachineImageEncryptionKey | object | |
startRestricted | boolean | [Output Only] Whether a VM has been restricted for start because Compute Engine has detected suspicious activity. |
status | string | [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. |
tags | object | A set of instance tags. |
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. |
Methods
Name | Accessible by | Required Params | Description |
---|---|---|---|
aggregated_list | SELECT | project | Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true . |
get | SELECT | instance, project, zone | Returns the specified Instance resource. |
list | SELECT | project, zone | Retrieves the list of instances contained within the specified zone. |
bulk_insert | INSERT | project, zone | Creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs. |
insert | INSERT | project, zone | Creates an instance resource in the specified project using the data included in the request. |
delete | DELETE | instance, project, zone | Deletes the specified Instance resource. For more information, see Deleting an instance. |
update | REPLACE | instance, project, zone | Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties. |
attach_disk | EXEC | instance, project, zone | Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance. |
detach_disk | EXEC | deviceName, instance, project, zone | Detaches a disk from an instance. |
perform_maintenance | EXEC | instance, project, zone | Perform a manual maintenance on the instance. |
reset | EXEC | instance, project, zone | Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance. |
resume | EXEC | instance, project, zone | Resumes an instance that was suspended using the instances().suspend method. |
send_diagnostic_interrupt | EXEC | instance, project, zone | Sends diagnostic interrupt to the instance. |
set_deletion_protection | EXEC | project, resource, zone | Sets deletion protection on the instance. |
set_disk_auto_delete | EXEC | autoDelete, deviceName, instance, project, zone | Sets the auto-delete flag for a disk attached to an instance. |
set_labels | EXEC | instance, project, zone | Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation. |
set_machine_resources | EXEC | instance, project, zone | Changes the number and/or type of accelerator for a stopped instance to the values specified in the request. |
set_machine_type | EXEC | instance, project, zone | Changes the machine type for a stopped instance to the machine type specified in the request. |
set_metadata | EXEC | instance, project, zone | Sets metadata for the specified instance to the data included in the request. |
set_min_cpu_platform | EXEC | instance, project, zone | Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform. |
set_name | EXEC | instance, project, zone | Sets name of an instance. |
set_scheduling | EXEC | instance, project, zone | Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a TERMINATED state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy. |
set_security_policy | EXEC | instance, project, zone | Sets the Google Cloud Armor security policy for the specified instance. For more information, see Google Cloud Armor Overview |
set_service_account | EXEC | instance, project, zone | Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance. |
set_shielded_instance_integrity_policy | EXEC | instance, project, zone | Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. |
set_tags | EXEC | instance, project, zone | Sets network tags for the specified instance to the data included in the request. |
simulate_maintenance_event | EXEC | instance, project, zone | Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event. |
start | EXEC | instance, project, zone | Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. |
start_with_encryption_key | EXEC | instance, project, zone | Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. |
stop | EXEC | instance, project, zone | Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance. |
suspend | EXEC | instance, project, zone | This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance. |
SELECT
examples
Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. To prevent failure, Google recommends that you set the returnPartialSuccess
parameter to true
.
SELECT
id,
name,
description,
advancedMachineFeatures,
canIpForward,
confidentialInstanceConfig,
cpuPlatform,
creationTimestamp,
deletionProtection,
disks,
displayDevice,
fingerprint,
guestAccelerators,
hostname,
instanceEncryptionKey,
keyRevocationActionType,
kind,
labelFingerprint,
labels,
lastStartTimestamp,
lastStopTimestamp,
lastSuspendedTimestamp,
machineType,
metadata,
minCpuPlatform,
networkInterfaces,
networkPerformanceConfig,
params,
privateIpv6GoogleAccess,
reservationAffinity,
resourcePolicies,
resourceStatus,
satisfiesPzi,
satisfiesPzs,
scheduling,
selfLink,
serviceAccounts,
shieldedInstanceConfig,
shieldedInstanceIntegrityPolicy,
sourceMachineImage,
sourceMachineImageEncryptionKey,
startRestricted,
status,
statusMessage,
tags,
zone
FROM google.compute.instances
WHERE project = '{{ project }}';
INSERT
example
Use the following StackQL query and manifest file to create a new instances
resource.
- All Properties
- Manifest
/*+ create */
INSERT INTO google.compute.instances (
project,
zone,
count,
minCount,
namePattern,
perInstanceProperties,
sourceInstanceTemplate,
instanceProperties,
locationPolicy
)
SELECT
'{{ project }}',
'{{ zone }}',
'{{ count }}',
'{{ minCount }}',
'{{ namePattern }}',
'{{ perInstanceProperties }}',
'{{ sourceInstanceTemplate }}',
'{{ instanceProperties }}',
'{{ locationPolicy }}'
;
- name: your_resource_model_name
props:
- name: count
value: string
- name: minCount
value: string
- name: namePattern
value: string
- name: perInstanceProperties
value: object
- name: sourceInstanceTemplate
value: string
- name: instanceProperties
value:
- name: description
value: string
- name: tags
value:
- name: items
value:
- string
- name: fingerprint
value: string
- name: resourceManagerTags
value: object
- name: machineType
value: string
- name: canIpForward
value: boolean
- name: networkInterfaces
value:
- - name: kind
value: string
- name: network
value: string
- name: subnetwork
value: string
- name: networkIP
value: string
- name: ipv6Address
value: string
- name: internalIpv6PrefixLength
value: integer
- name: name
value: string
- name: accessConfigs
value:
- - name: kind
value: string
- name: type
value: string
- name: name
value: string
- name: natIP
value: string
- name: externalIpv6
value: string
- name: externalIpv6PrefixLength
value: integer
- name: setPublicPtr
value: boolean
- name: publicPtrDomainName
value: string
- name: networkTier
value: string
- name: securityPolicy
value: string
- name: ipv6AccessConfigs
value:
- - name: kind
value: string
- name: type
value: string
- name: name
value: string
- name: natIP
value: string
- name: externalIpv6
value: string
- name: externalIpv6PrefixLength
value: integer
- name: setPublicPtr
value: boolean
- name: publicPtrDomainName
value: string
- name: networkTier
value: string
- name: securityPolicy
value: string
- name: aliasIpRanges
value:
- - name: ipCidrRange
value: string
- name: subnetworkRangeName
value: string
- name: fingerprint
value: string
- name: stackType
value: string
- name: ipv6AccessType
value: string
- name: queueCount
value: integer
- name: nicType
value: string
- name: networkAttachment
value: string
- name: disks
value:
- - name: kind
value: string
- name: type
value: string
- name: mode
value: string
- name: savedState
value: string
- name: source
value: string
- name: deviceName
value: string
- name: index
value: integer
- name: boot
value: boolean
- name: initializeParams
value:
- name: diskName
value: string
- name: sourceImage
value: string
- name: diskSizeGb
value: string
- name: diskType
value: string
- name: sourceImageEncryptionKey
value:
- name: rawKey
value: string
- name: rsaEncryptedKey
value: string
- name: kmsKeyName
value: string
- name: sha256
value: string
- name: kmsKeyServiceAccount
value: string
- name: labels
value: object
- name: sourceSnapshot
value: string
- name: description
value: string
- name: replicaZones
value:
- string
- name: resourcePolicies
value:
- string
- name: onUpdateAction
value: string
- name: provisionedIops
value: string
- name: licenses
value:
- string
- name: architecture
value: string
- name: resourceManagerTags
value: object
- name: provisionedThroughput
value: string
- name: enableConfidentialCompute
value: boolean
- name: storagePool
value: string
- name: autoDelete
value: boolean
- name: licenses
value:
- string
- name: interface
value: string
- name: guestOsFeatures
value:
- - name: type
value: string
- name: diskSizeGb
value: string
- name: shieldedInstanceInitialState
value:
- name: pk
value:
- name: content
value: string
- name: fileType
value: string
- name: keks
value:
- - name: content
value: string
- name: fileType
value: string
- name: dbs
value:
- - name: content
value: string
- name: fileType
value: string
- name: dbxs
value:
- - name: content
value: string
- name: fileType
value: string
- name: forceAttach
value: boolean
- name: architecture
value: string
- name: metadata
value:
- name: kind
value: string
- name: fingerprint
value: string
- name: items
value:
- - name: key
value: string
- name: value
value: string
- name: serviceAccounts
value:
- - name: email
value: string
- name: scopes
value:
- string
- name: scheduling
value:
- name: onHostMaintenance
value: string
- name: automaticRestart
value: boolean
- name: preemptible
value: boolean
- name: nodeAffinities
value:
- - name: key
value: string
- name: operator
value: string
- name: values
value:
- string
- name: minNodeCpus
value: integer
- name: locationHint
value: string
- name: availabilityDomain
value: integer
- name: provisioningModel
value: string
- name: instanceTerminationAction
value: string
- name: maxRunDuration
value:
- name: seconds
value: string
- name: nanos
value: integer
- name: terminationTime
value: string
- name: onInstanceStopAction
value:
- name: discardLocalSsd
value: boolean
- name: labels
value: object
- name: guestAccelerators
value:
- - name: acceleratorType
value: string
- name: acceleratorCount
value: integer
- name: minCpuPlatform
value: string
- name: reservationAffinity
value:
- name: consumeReservationType
value: string
- name: key
value: string
- name: values
value:
- string
- name: shieldedInstanceConfig
value:
- name: enableSecureBoot
value: boolean
- name: enableVtpm
value: boolean
- name: enableIntegrityMonitoring
value: boolean
- name: resourcePolicies
value:
- string
- name: confidentialInstanceConfig
value:
- name: enableConfidentialCompute
value: boolean
- name: confidentialInstanceType
value: string
- name: privateIpv6GoogleAccess
value: string
- name: advancedMachineFeatures
value:
- name: enableNestedVirtualization
value: boolean
- name: threadsPerCore
value: integer
- name: visibleCoreCount
value: integer
- name: enableUefiNetworking
value: boolean
- name: performanceMonitoringUnit
value: string
- name: turboMode
value: string
- name: networkPerformanceConfig
value:
- name: totalEgressBandwidthTier
value: string
- name: keyRevocationActionType
value: string
- name: locationPolicy
value:
- name: locations
value: object
- name: targetShape
value: string
REPLACE
example
Replaces all fields in the specified instances
resource.
/*+ update */
REPLACE google.compute.instances
SET
name = '{{ name }}',
description = '{{ description }}',
tags = '{{ tags }}',
machineType = '{{ machineType }}',
status = '{{ status }}',
statusMessage = '{{ statusMessage }}',
zone = '{{ zone }}',
canIpForward = true|false,
networkInterfaces = '{{ networkInterfaces }}',
disks = '{{ disks }}',
metadata = '{{ metadata }}',
serviceAccounts = '{{ serviceAccounts }}',
scheduling = '{{ scheduling }}',
cpuPlatform = '{{ cpuPlatform }}',
labels = '{{ labels }}',
params = '{{ params }}',
labelFingerprint = '{{ labelFingerprint }}',
instanceEncryptionKey = '{{ instanceEncryptionKey }}',
minCpuPlatform = '{{ minCpuPlatform }}',
guestAccelerators = '{{ guestAccelerators }}',
startRestricted = true|false,
deletionProtection = true|false,
resourcePolicies = '{{ resourcePolicies }}',
sourceMachineImage = '{{ sourceMachineImage }}',
reservationAffinity = '{{ reservationAffinity }}',
hostname = '{{ hostname }}',
displayDevice = '{{ displayDevice }}',
shieldedInstanceConfig = '{{ shieldedInstanceConfig }}',
shieldedInstanceIntegrityPolicy = '{{ shieldedInstanceIntegrityPolicy }}',
sourceMachineImageEncryptionKey = '{{ sourceMachineImageEncryptionKey }}',
confidentialInstanceConfig = '{{ confidentialInstanceConfig }}',
fingerprint = '{{ fingerprint }}',
privateIpv6GoogleAccess = '{{ privateIpv6GoogleAccess }}',
advancedMachineFeatures = '{{ advancedMachineFeatures }}',
lastStartTimestamp = '{{ lastStartTimestamp }}',
lastStopTimestamp = '{{ lastStopTimestamp }}',
lastSuspendedTimestamp = '{{ lastSuspendedTimestamp }}',
satisfiesPzs = true|false,
satisfiesPzi = true|false,
resourceStatus = '{{ resourceStatus }}',
networkPerformanceConfig = '{{ networkPerformanceConfig }}',
keyRevocationActionType = '{{ keyRevocationActionType }}'
WHERE
instance = '{{ instance }}'
AND project = '{{ project }}'
AND zone = '{{ zone }}';
DELETE
example
Deletes the specified instances
resource.
/*+ delete */
DELETE FROM google.compute.instances
WHERE instance = '{{ instance }}'
AND project = '{{ project }}'
AND zone = '{{ zone }}';