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
| Name | Datatype | Description |
|---|---|---|
id | string (uint64) | Output only. [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 withRFC1035. 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](?:[-a-z0-9]{0,61}[a-z0-9])?) |
creationTimestamp | string | Output only. [Output Only] The creation timestamp for this machine image inRFC3339 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. [Output Only] The resource type, which is alwayscompute#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 acustomer-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) |
params | object | Input only. [Input Only] Additional parameters that are passed in the request, but are not persisted in the resource. (id: MachineImageParams) |
satisfiesPzi | boolean | Output only. Reserved for future use. |
satisfiesPzs | boolean | Output only. [Output Only] Reserved for future use. |
savedDisks | array | Output only. An array of Machine Image specific properties for disks attached to the source instance |
selfLink | string | Output only. [Output Only] The URL for this machine image. The server defines this URL. |
sourceDiskEncryptionKeys | array | [Input Only] Thecustomer-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. [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. [Output Only] The status of the machine image. One of the following values:INVALID, CREATING, READY,DELETING, and UPLOADING. (CREATING, DELETING, INVALID, READY, UPLOADING) |
storageLocations | array | The regional or multi-regional Cloud Storage bucket location where themachine image is stored. |
totalStorageBytes | string (int64) | Output only. [Output Only] Total size of the storage used by the machine image. |
| 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. [Output Only] The resource type, which is alwayscompute#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 thanmaxResults, 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. [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 | orderBy, filter, maxResults, pageToken, returnPartialSuccess | Retrieves a list of machine images that are contained within the specified project. |
insert | insert | project | sourceInstance, requestId | 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 theLabeling 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,
params,
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 orderBy = '{{ orderBy }}'
AND filter = '{{ filter }}'
AND maxResults = '{{ maxResults }}'
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__machineImageEncryptionKey,
data__sourceInstance,
data__instanceProperties,
data__storageLocations,
data__sourceDiskEncryptionKeys,
data__name,
data__guestFlush,
data__params,
data__labelFingerprint,
data__labels,
data__description,
project,
sourceInstance,
requestId
)
SELECT
'{{ machineImageEncryptionKey }}',
'{{ sourceInstance }}',
'{{ instanceProperties }}',
'{{ storageLocations }}',
'{{ sourceDiskEncryptionKeys }}',
'{{ name }}',
{{ guestFlush }},
'{{ params }}',
'{{ labelFingerprint }}',
'{{ labels }}',
'{{ description }}',
'{{ project }}',
'{{ sourceInstance }}',
'{{ requestId }}'
RETURNING
id,
name,
clientOperationId,
creationTimestamp,
description,
endTime,
error,
getVersionOperationMetadata,
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: "{{ project }}"
description: Required parameter for the machine_images resource.
- name: machineImageEncryptionKey
description: |
Encrypts the machine image using acustomer-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.
value:
rawKey: "{{ rawKey }}"
kmsKeyServiceAccount: "{{ kmsKeyServiceAccount }}"
rsaEncryptedKey: "{{ rsaEncryptedKey }}"
kmsKeyName: "{{ kmsKeyName }}"
sha256: "{{ sha256 }}"
- name: sourceInstance
value: "{{ sourceInstance }}"
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: instanceProperties
description: |
[Output Only] Properties of source instance
value:
scheduling:
onHostMaintenance: "{{ onHostMaintenance }}"
hostErrorTimeoutSeconds: {{ hostErrorTimeoutSeconds }}
provisioningModel: "{{ provisioningModel }}"
availabilityDomain: {{ availabilityDomain }}
onInstanceStopAction:
discardLocalSsd: {{ discardLocalSsd }}
nodeAffinities:
- values: "{{ values }}"
key: "{{ key }}"
operator: "{{ operator }}"
maxRunDuration:
nanos: {{ nanos }}
seconds: "{{ seconds }}"
instanceTerminationAction: "{{ instanceTerminationAction }}"
preemptionNoticeDuration:
nanos: {{ nanos }}
seconds: "{{ seconds }}"
preemptible: {{ preemptible }}
skipGuestOsShutdown: {{ skipGuestOsShutdown }}
terminationTime: "{{ terminationTime }}"
localSsdRecoveryTimeout:
nanos: {{ nanos }}
seconds: "{{ seconds }}"
minNodeCpus: {{ minNodeCpus }}
gracefulShutdown:
enabled: {{ enabled }}
maxDuration:
nanos: {{ nanos }}
seconds: "{{ seconds }}"
automaticRestart: {{ automaticRestart }}
locationHint: "{{ locationHint }}"
guestAccelerators:
- acceleratorType: "{{ acceleratorType }}"
acceleratorCount: {{ acceleratorCount }}
privateIpv6GoogleAccess: "{{ privateIpv6GoogleAccess }}"
reservationAffinity:
consumeReservationType: "{{ consumeReservationType }}"
key: "{{ key }}"
values:
- "{{ values }}"
machineType: "{{ machineType }}"
shieldedInstanceConfig:
enableSecureBoot: {{ enableSecureBoot }}
enableIntegrityMonitoring: {{ enableIntegrityMonitoring }}
enableVtpm: {{ enableVtpm }}
networkPerformanceConfig:
totalEgressBandwidthTier: "{{ totalEgressBandwidthTier }}"
resourcePolicies:
- "{{ resourcePolicies }}"
canIpForward: {{ canIpForward }}
localSsdEncryptionMode: "{{ localSsdEncryptionMode }}"
tags:
items:
- "{{ items }}"
fingerprint: "{{ fingerprint }}"
minCpuPlatform: "{{ minCpuPlatform }}"
confidentialInstanceConfig:
enableConfidentialCompute: {{ enableConfidentialCompute }}
confidentialInstanceType: "{{ confidentialInstanceType }}"
workloadIdentityConfig:
identityCertificateEnabled: {{ identityCertificateEnabled }}
identity: "{{ identity }}"
networkInterfaces:
- ipv6Address: "{{ ipv6Address }}"
parentNicName: "{{ parentNicName }}"
fingerprint: "{{ fingerprint }}"
igmpQuery: "{{ igmpQuery }}"
serviceClassId: "{{ serviceClassId }}"
subnetwork: "{{ subnetwork }}"
network: "{{ network }}"
stackType: "{{ stackType }}"
ipv6AccessType: "{{ ipv6AccessType }}"
accessConfigs: "{{ accessConfigs }}"
networkAttachment: "{{ networkAttachment }}"
queueCount: {{ queueCount }}
name: "{{ name }}"
kind: "{{ kind }}"
networkIP: "{{ networkIP }}"
vlan: {{ vlan }}
internalIpv6PrefixLength: {{ internalIpv6PrefixLength }}
nicType: "{{ nicType }}"
aliasIpRanges: "{{ aliasIpRanges }}"
ipv6AccessConfigs: "{{ ipv6AccessConfigs }}"
aliasIpv6Ranges: "{{ aliasIpv6Ranges }}"
enableVpcScopedDns: {{ enableVpcScopedDns }}
serviceAccounts:
- scopes: "{{ scopes }}"
email: "{{ email }}"
keyRevocationActionType: "{{ keyRevocationActionType }}"
metadata:
fingerprint: "{{ fingerprint }}"
items:
- key: "{{ key }}"
value: "{{ value }}"
kind: "{{ kind }}"
description: "{{ description }}"
disks:
- diskSizeGb: "{{ diskSizeGb }}"
boot: {{ boot }}
architecture: "{{ architecture }}"
deviceName: "{{ deviceName }}"
savedState: "{{ savedState }}"
diskEncryptionKey:
rawKey: "{{ rawKey }}"
kmsKeyServiceAccount: "{{ kmsKeyServiceAccount }}"
rsaEncryptedKey: "{{ rsaEncryptedKey }}"
kmsKeyName: "{{ kmsKeyName }}"
sha256: "{{ sha256 }}"
interface: "{{ interface }}"
mode: "{{ mode }}"
source: "{{ source }}"
kind: "{{ kind }}"
licenses: "{{ licenses }}"
shieldedInstanceInitialState:
pk:
content: "{{ content }}"
fileType: "{{ fileType }}"
keks:
- content: "{{ content }}"
fileType: "{{ fileType }}"
dbs:
- content: "{{ content }}"
fileType: "{{ fileType }}"
dbxs:
- content: "{{ content }}"
fileType: "{{ fileType }}"
type: "{{ type }}"
index: {{ index }}
autoDelete: {{ autoDelete }}
guestOsFeatures: "{{ guestOsFeatures }}"
forceAttach: {{ forceAttach }}
initializeParams:
resourcePolicies:
- "{{ resourcePolicies }}"
storagePool: "{{ storagePool }}"
replicaZones:
- "{{ replicaZones }}"
diskSizeGb: "{{ diskSizeGb }}"
architecture: "{{ architecture }}"
sourceImage: "{{ sourceImage }}"
enableConfidentialCompute: {{ enableConfidentialCompute }}
sourceImageEncryptionKey:
rawKey: "{{ rawKey }}"
kmsKeyServiceAccount: "{{ kmsKeyServiceAccount }}"
rsaEncryptedKey: "{{ rsaEncryptedKey }}"
kmsKeyName: "{{ kmsKeyName }}"
sha256: "{{ sha256 }}"
description: "{{ description }}"
provisionedIops: "{{ provisionedIops }}"
labels: "{{ labels }}"
provisionedThroughput: "{{ provisionedThroughput }}"
diskName: "{{ diskName }}"
sourceSnapshotEncryptionKey:
rawKey: "{{ rawKey }}"
kmsKeyServiceAccount: "{{ kmsKeyServiceAccount }}"
rsaEncryptedKey: "{{ rsaEncryptedKey }}"
kmsKeyName: "{{ kmsKeyName }}"
sha256: "{{ sha256 }}"
resourceManagerTags: "{{ resourceManagerTags }}"
diskType: "{{ diskType }}"
licenses:
- "{{ licenses }}"
onUpdateAction: "{{ onUpdateAction }}"
sourceSnapshot: "{{ sourceSnapshot }}"
advancedMachineFeatures:
enableUefiNetworking: {{ enableUefiNetworking }}
performanceMonitoringUnit: "{{ performanceMonitoringUnit }}"
threadsPerCore: {{ threadsPerCore }}
visibleCoreCount: {{ visibleCoreCount }}
enableNestedVirtualization: {{ enableNestedVirtualization }}
turboMode: "{{ turboMode }}"
labels: "{{ labels }}"
resourceManagerTags: "{{ resourceManagerTags }}"
- name: storageLocations
value:
- "{{ storageLocations }}"
description: |
The regional or multi-regional Cloud Storage bucket location where themachine image is
stored.
- name: sourceDiskEncryptionKeys
description: |
[Input Only] Thecustomer-supplied
encryption key of the disks attached to the source instance. Required
if the source disk is protected by a customer-supplied encryption key.
value:
- sourceDisk: "{{ sourceDisk }}"
diskEncryptionKey:
rawKey: "{{ rawKey }}"
kmsKeyServiceAccount: "{{ kmsKeyServiceAccount }}"
rsaEncryptedKey: "{{ rsaEncryptedKey }}"
kmsKeyName: "{{ kmsKeyName }}"
sha256: "{{ sha256 }}"
- name: name
value: "{{ name }}"
description: |
Name of the resource; provided by the client when the resource is created.
The name must be 1-63 characters long, and comply withRFC1035.
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: guestFlush
value: {{ guestFlush }}
description: |
[Input Only] Whether to attempt an application consistent machine image by
informing the OS to prepare for the snapshot process.
- name: params
description: |
Input only. [Input Only] Additional parameters that are passed in the request, but are
not persisted in the resource.
value:
resourceManagerTags: "{{ resourceManagerTags }}"
- name: labelFingerprint
value: "{{ labelFingerprint }}"
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: labels
value: "{{ labels }}"
description: |
Labels to apply to this machine image. These can be later modified by
the setLabels method.
- name: description
value: "{{ description }}"
description: |
An optional description of this resource. Provide this property when you
create the resource.
- name: sourceInstance
value: "{{ sourceInstance }}"
- name: requestId
value: "{{ requestId }}"
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 theLabeling
Resources documentation.
EXEC google.compute.machine_images.set_labels
@project='{{ project }}' --required,
@resource='{{ resource }}' --required
@@json=
'{
"labels": "{{ labels }}",
"labelFingerprint": "{{ labelFingerprint }}"
}'
;