machine_images
Creates, updates, deletes, gets or lists a machine_images
resource.
Overview
Name | machine_images |
Type | Resource |
Id | google.compute.machine_images |
Fields
The following fields are returned by SELECT
queries:
- get
- list
Successful response
Name | Datatype | Description |
---|---|---|
id | string (uint64) | [Output Only] A unique identifier for this machine image. The server defines this identifier. |
name | string | Name 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?) |
creationTimestamp | string | [Output Only] The creation timestamp for this machine image in RFC3339 text format. |
description | string | An optional description of this resource. Provide this property when you create the resource. |
guestFlush | boolean | [Input Only] Whether to attempt an application consistent machine image by informing the OS to prepare for the snapshot process. |
instanceProperties | object | [Output Only] Properties of source instance (id: InstanceProperties) |
kind | string | [Output Only] The resource type, which is always compute#machineImage for machine image. (default: compute#machineImage) |
labelFingerprint | string (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. |
labels | object | Labels to apply to this machine image. These can be later modified by the setLabels method. |
machineImageEncryptionKey | object | Encrypts 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) |
satisfiesPzi | boolean | Output only. Reserved for future use. |
satisfiesPzs | boolean | [Output Only] Reserved for future use. |
savedDisks | array | An array of Machine Image specific properties for disks attached to the source instance |
selfLink | string | [Output Only] The URL for this machine image. The server defines this URL. |
sourceDiskEncryptionKeys | array | [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. |
sourceInstance | string | The 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 |
sourceInstanceProperties | object | [Output Only] DEPRECATED: Please use instance_properties instead for source instance related properties. New properties will not be added to this field. (id: SourceInstanceProperties) |
status | string | [Output Only] The status of the machine image. One of the following values: INVALID, CREATING, READY, DELETING, and UPLOADING. |
storageLocations | array | The regional or multi-regional Cloud Storage bucket location where the machine image is stored. |
totalStorageBytes | string (int64) | [Output Only] Total size of the storage used by the machine image. |
Successful response
Name | Datatype | Description |
---|---|---|
id | string | [Output Only] Unique identifier for the resource; defined by the server. |
items | array | A list of MachineImage resources. |
kind | string | [Output Only] The resource type, which is always compute#machineImagesListResponse for machine image lists. (default: compute#machineImageList) |
nextPageToken | string | [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. |
selfLink | string | [Output Only] Server-defined URL for this resource. |
warning | object | [Output Only] Informational warning message. |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
get | select | project , machineImage | Returns the specified machine image. | |
list | select | project | filter , maxResults , orderBy , pageToken , returnPartialSuccess | Retrieves a list of machine images that are contained within the specified project. |
insert | insert | project | requestId , sourceInstance | 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. |
delete | delete | project , machineImage | requestId | Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone. |
set_labels | exec | project , resource | Sets 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.
Name | Datatype | Description |
---|---|---|
machineImage | string | |
project | string | |
resource | string | |
filter | string | |
maxResults | integer (uint32) | |
orderBy | string | |
pageToken | string | |
requestId | string | |
returnPartialSuccess | boolean | |
sourceInstance | string |
SELECT
examples
- get
- list
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;
Retrieves a list of machine images that are contained within the specified project.
SELECT
id,
items,
kind,
nextPageToken,
selfLink,
warning
FROM google.compute.machine_images
WHERE project = '{{ project }}' -- required
AND filter = '{{ filter }}'
AND maxResults = '{{ maxResults }}'
AND orderBy = '{{ orderBy }}'
AND pageToken = '{{ pageToken }}'
AND returnPartialSuccess = '{{ returnPartialSuccess }}';
INSERT
examples
- insert
- Manifest
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
;
# Description fields are for documentation purposes
- name: machine_images
props:
- name: project
value: string
description: Required parameter for the machine_images resource.
- name: kind
value: string
description: >
[Output Only] The resource type, which is always compute#machineImage for machine image.
default: compute#machineImage
- name: id
value: string
description: >
[Output Only] A unique identifier for this machine image. The server defines this identifier.
- name: creationTimestamp
value: string
description: >
[Output Only] The creation timestamp for this machine image in RFC3339 text format.
- name: name
value: string
description: >
Name 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.
- name: description
value: string
description: >
An optional description of this resource. Provide this property when you create the resource.
- name: selfLink
value: string
description: >
[Output Only] The URL for this machine image. The server defines this URL.
- name: sourceInstance
value: string
description: >
The 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
- name: status
value: string
description: >
[Output Only] The status of the machine image. One of the following values: INVALID, CREATING, READY, DELETING, and UPLOADING.
valid_values: ['CREATING', 'DELETING', 'INVALID', 'READY', 'UPLOADING']
- name: sourceInstanceProperties
value: object
description: >
[Output Only] DEPRECATED: Please use instance_properties instead for source instance related properties. New properties will not be added to this field.
- name: instanceProperties
value: object
description: >
[Output Only] Properties of source instance
- name: savedDisks
value: array
description: >
An array of Machine Image specific properties for disks attached to the source instance
- name: storageLocations
value: array
description: >
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
- name: machineImageEncryptionKey
value: object
description: >
Encrypts 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.
- name: labels
value: object
description: >
Labels to apply to this machine image. These can be later modified by the setLabels method.
- name: labelFingerprint
value: string
description: >
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.
- name: guestFlush
value: boolean
description: >
[Input Only] Whether to attempt an application consistent machine image by informing the OS to prepare for the snapshot process.
- name: sourceDiskEncryptionKeys
value: array
description: >
[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.
- name: totalStorageBytes
value: string
description: >
[Output Only] Total size of the storage used by the machine image.
- name: satisfiesPzs
value: boolean
description: >
[Output Only] Reserved for future use.
- name: requestId
value: string
- name: sourceInstance
value: string
DELETE
examples
- delete
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
- set_labels
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 }}"
}';