Skip to main content

machine_images

Creates, updates, deletes, gets or lists a machine_images resource.

Overview

Namemachine_images
TypeResource
Idgoogle.compute.machine_images

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
idstring (uint64)[Output Only] A unique identifier for this machine image. The server defines this identifier.
namestringName of the resource; provided by the client when the resource is created. The 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. (pattern: a-z?)
creationTimestampstring[Output Only] The creation timestamp for this machine image in RFC3339 text format.
descriptionstringAn optional description of this resource. Provide this property when you create the resource.
guestFlushboolean[Input Only] Whether to attempt an application consistent machine image by informing the OS to prepare for the snapshot process.
instancePropertiesobject[Output Only] Properties of source instance (id: InstanceProperties)
kindstring[Output Only] The resource type, which is always compute#machineImage for machine image. (default: compute#machineImage)
labelFingerprintstring (byte)A fingerprint for the labels being applied to this machine image, which is essentially a hash of the labels set 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 machine image.
labelsobjectLabels to apply to this machine image. These can be later modified by the setLabels method.
machineImageEncryptionKeyobjectEncrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image using a customer-supplied key, you must provide the same key if you use the machine image later. For example, you must provide the encryption key when you create an instance from the encrypted machine image in a future request. Customer-supplied encryption keys do not protect access to metadata of the machine image. If you do not provide an encryption key when creating the machine image, then the machine image will be encrypted using an automatically generated key and you do not need to provide a key to use the machine image later. (id: CustomerEncryptionKey)
satisfiesPzibooleanOutput only. Reserved for future use.
satisfiesPzsboolean[Output Only] Reserved for future use.
savedDisksarrayAn array of Machine Image specific properties for disks attached to the source instance
selfLinkstring[Output Only] The URL for this machine image. The server defines this URL.
sourceDiskEncryptionKeysarray[Input Only] The customer-supplied encryption key of the disks attached to the source instance. Required if the source disk is protected by a customer-supplied encryption key.
sourceInstancestringThe source instance used to create the machine image. You can provide this as a partial or full URL to the resource. For example, the following are valid values: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /instances/instance - projects/project/zones/zone/instances/instance
sourceInstancePropertiesobject[Output Only] DEPRECATED: Please use instance_properties instead for source instance related properties. New properties will not be added to this field. (id: SourceInstanceProperties)
statusstring[Output Only] The status of the machine image. One of the following values: INVALID, CREATING, READY, DELETING, and UPLOADING.
storageLocationsarrayThe regional or multi-regional Cloud Storage bucket location where the machine image is stored.
totalStorageBytesstring (int64)[Output Only] Total size of the storage used by the machine image.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectproject, machineImageReturns the specified machine image.
listselectprojectfilter, maxResults, orderBy, pageToken, returnPartialSuccessRetrieves a list of machine images that are contained within the specified project.
insertinsertprojectrequestId, sourceInstanceCreates a machine image in the specified project using the data that is included in the request. If you are creating a new machine image to update an existing instance, your new machine image should use the same network or, if applicable, the same subnetwork as the original instance.
deletedeleteproject, machineImagerequestIdDeletes the specified machine image. Deleting a machine image is permanent and cannot be undone.
set_labelsexecproject, resourceSets the labels on a machine image. To learn more about labels, read the Labeling Resources documentation.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
machineImagestring
projectstring
resourcestring
filterstring
maxResultsinteger (uint32)
orderBystring
pageTokenstring
requestIdstring
returnPartialSuccessboolean
sourceInstancestring

SELECT examples

Returns the specified machine image.

SELECT
id,
name,
creationTimestamp,
description,
guestFlush,
instanceProperties,
kind,
labelFingerprint,
labels,
machineImageEncryptionKey,
satisfiesPzi,
satisfiesPzs,
savedDisks,
selfLink,
sourceDiskEncryptionKeys,
sourceInstance,
sourceInstanceProperties,
status,
storageLocations,
totalStorageBytes
FROM google.compute.machine_images
WHERE project = '{{ project }}' -- required
AND machineImage = '{{ machineImage }}' -- required;

INSERT examples

Creates a machine image in the specified project using the data that is included in the request. If you are creating a new machine image to update an existing instance, your new machine image should use the same network or, if applicable, the same subnetwork as the original instance.

INSERT INTO google.compute.machine_images (
data__kind,
data__id,
data__creationTimestamp,
data__name,
data__description,
data__selfLink,
data__sourceInstance,
data__status,
data__sourceInstanceProperties,
data__instanceProperties,
data__savedDisks,
data__storageLocations,
data__machineImageEncryptionKey,
data__labels,
data__labelFingerprint,
data__guestFlush,
data__sourceDiskEncryptionKeys,
data__totalStorageBytes,
data__satisfiesPzs,
project,
requestId,
sourceInstance
)
SELECT
'{{ kind }}',
'{{ id }}',
'{{ creationTimestamp }}',
'{{ name }}',
'{{ description }}',
'{{ selfLink }}',
'{{ sourceInstance }}',
'{{ status }}',
'{{ sourceInstanceProperties }}',
'{{ instanceProperties }}',
'{{ savedDisks }}',
'{{ storageLocations }}',
'{{ machineImageEncryptionKey }}',
'{{ labels }}',
'{{ labelFingerprint }}',
{{ guestFlush }},
'{{ sourceDiskEncryptionKeys }}',
'{{ totalStorageBytes }}',
{{ satisfiesPzs }},
'{{ project }}',
'{{ requestId }}',
'{{ sourceInstance }}'
RETURNING
id,
name,
clientOperationId,
creationTimestamp,
description,
endTime,
error,
httpErrorMessage,
httpErrorStatusCode,
insertTime,
instancesBulkInsertOperationMetadata,
kind,
operationGroupId,
operationType,
progress,
region,
selfLink,
setCommonInstanceMetadataOperationMetadata,
startTime,
status,
statusMessage,
targetId,
targetLink,
user,
warnings,
zone
;

DELETE examples

Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone.

DELETE FROM google.compute.machine_images
WHERE project = '{{ project }}' --required
AND machineImage = '{{ machineImage }}' --required
AND requestId = '{{ requestId }}';

Lifecycle Methods

Sets the labels on a machine image. To learn more about labels, read the Labeling Resources documentation.

EXEC google.compute.machine_images.set_labels 
@project='{{ project }}' --required,
@resource='{{ resource }}' --required
@@json=
'{
"labels": "{{ labels }}",
"labelFingerprint": "{{ labelFingerprint }}"
}';