Skip to content

Commit 9758a99

Browse files
karolgorcRooBarsic
authored andcommitted
Add missing field to disks and support InstantSnapshot (GoogleCloudPlatform#12946)
1 parent c04c740 commit 9758a99

File tree

6 files changed

+543
-1
lines changed

6 files changed

+543
-1
lines changed

mmv1/products/compute/Disk.yaml

+52-1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,27 @@ properties:
144144
description: |
145145
The service account used for the encryption request for the given KMS key.
146146
If absent, the Compute Engine Service Agent service account is used.
147+
- name: 'sourceInstantSnapshot'
148+
type: String
149+
description: |
150+
The source instant snapshot used to create this disk. You can provide this as a partial or full URL to the resource.
151+
For example, the following are valid values:
152+
153+
* `https://www.googleapis.com/compute/v1/projects/project/zones/zone/instantSnapshots/instantSnapshot`
154+
* `projects/project/zones/zone/instantSnapshots/instantSnapshot`
155+
* `zones/zone/instantSnapshots/instantSnapshot`
156+
resource: 'Snapshot'
157+
imports: 'selfLink'
158+
diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName'
159+
- name: 'sourceInstantSnapshotId'
160+
type: String
161+
description: |
162+
The unique ID of the instant snapshot used to create this disk. This value identifies
163+
the exact instant snapshot that was used to create this persistent disk.
164+
For example, if you created the persistent disk from an instant snapshot that was later
165+
deleted and recreated under the same name, the source instant snapshot ID would identify
166+
the exact version of the instant snapshot that was used.
167+
output: true
147168
- name: 'sourceImageId'
148169
type: String
149170
description: |
@@ -249,7 +270,15 @@ properties:
249270
snapshot ID would identify the exact version of the snapshot that was
250271
used.
251272
output: true
252-
273+
- name: 'sourceStorageObject'
274+
type: String
275+
description: |
276+
The full Google Cloud Storage URI where the disk image is stored.
277+
This file must be a gzip-compressed tarball whose name ends in .tar.gz or virtual machine disk whose name ends in vmdk.
278+
Valid URIs may start with gs:// or https://storage.googleapis.com/.
279+
This flag is not optimized for creating multiple disks from a source storage object.
280+
To create many disks from a source storage object, use gcloud compute images import instead.
281+
ignore_read: true
253282
- name: 'labelFingerprint'
254283
type: Fingerprint
255284
description: |
@@ -462,6 +491,28 @@ properties:
462491
description: |
463492
Primary disk for asynchronous disk replication.
464493
required: true
494+
- name: 'architecture'
495+
ignore_read: true
496+
type: String
497+
The architecture of the disk.
498+
enum_values:
499+
- 'X86_64'
500+
- 'ARM64'
501+
- name: 'params'
502+
type: NestedObject
503+
ignore_read: true
504+
immutable: true
505+
description: |
506+
Additional params passed with the request, but not persisted as part of resource payload
507+
properties:
508+
- name: 'resourceManagerTags'
509+
type: KeyValuePairs
510+
description: |
511+
Resource manager tags to be bound to the disk. Tag keys and values have the
512+
same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id},
513+
and values are in the format tagValues/456.
514+
api_name: resourceManagerTags
515+
ignore_read: true
465516
- name: 'guestOsFeatures'
466517
type: Array
467518
description: |
+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'InstantSnapshot'
16+
kind: 'compute#instantSnapshot'
17+
description: |
18+
Represents an instant snapshot resource.
19+
20+
An instant snapshot is an in-place backup of a disk that can be used to rapidly create a new disk in minutes.
21+
22+
Instant snapshots capture data at a specific point in time. They are optimized for rapidly restoring captured
23+
data to a new disk. Use instant snapshots to quickly recover data in cases where the zone and disk are still intact
24+
but the data on the disk has been lost or corrupted
25+
references:
26+
guides:
27+
'Official Documentation': 'https://cloud.google.com/compute/docs/disks/instant-snapshots'
28+
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/instantSnapshots'
29+
docs:
30+
base_url: 'projects/{{project}}/zones/{{zone}}/instantSnapshots'
31+
has_self_link: true
32+
immutable: true
33+
timeouts:
34+
insert_minutes: 20
35+
update_minutes: 20
36+
delete_minutes: 20
37+
async:
38+
actions: ['create', 'delete', 'update']
39+
type: 'OpAsync'
40+
operation:
41+
full_url: 'selfLink'
42+
result:
43+
resource_inside_response: false
44+
collection_url_key: 'items'
45+
iam_policy:
46+
parent_resource_attribute: 'name'
47+
example_config_body: 'templates/terraform/iam/iam_attributes.go.tmpl'
48+
iam_conditions_request_type: 'QUERY_PARAM'
49+
allowed_iam_role: 'roles/compute.storageAdmin'
50+
import_format:
51+
- 'projects/{{project}}/zones/{{zone}}/instantSnapshots/{{name}}'
52+
examples:
53+
- name: 'instant_snapshot_basic'
54+
primary_resource_id: 'default'
55+
primary_resource_name: 'fmt.Sprintf("tf-test-instant-snapshot%s", context["random_suffix"])'
56+
vars:
57+
instance_name: 'instant-snapshot'
58+
disk_name: 'example-disk'
59+
parameters:
60+
- name: 'sourceDisk'
61+
type: ResourceRef
62+
description: 'A reference to the disk used to create this instant snapshot.'
63+
required: true
64+
immutable: true
65+
diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName'
66+
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl'
67+
resource: 'Disk'
68+
imports: 'name'
69+
- name: 'zone'
70+
type: ResourceRef
71+
description: 'A reference to the zone where the disk is located.'
72+
default_from_api: true
73+
required: false
74+
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl'
75+
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl'
76+
resource: 'Zone'
77+
imports: 'name'
78+
properties:
79+
- name: 'creationTimestamp'
80+
type: Time
81+
description: 'Creation timestamp in RFC3339 text format.'
82+
output: true
83+
- name: 'name'
84+
type: String
85+
description: |
86+
Name of the resource; provided by the client when the resource is
87+
created. The name must be 1-63 characters long, and comply with
88+
RFC1035. Specifically, the name must be 1-63 characters long and match
89+
the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the
90+
first character must be a lowercase letter, and all following
91+
characters must be a dash, lowercase letter, or digit, except the last
92+
character, which cannot be a dash.
93+
required: true
94+
immutable: true
95+
- name: 'description'
96+
type: String
97+
description: 'An optional description of this resource.'
98+
required: false
99+
- name: 'sourceDiskId'
100+
type: String
101+
description: 'The ID value of the disk used to create this InstantSnapshot.'
102+
output: true
103+
- name: 'diskSizeGb'
104+
type: Integer
105+
description: 'Size of the snapshot, specified in GB.'
106+
output: true
107+
- name: 'labels'
108+
type: KeyValueLabels
109+
description: Labels to apply to this InstantSnapshot.
110+
update_url: 'projects/{{project}}/zones/{{zone}}/instantSnapshots/{{name}}/setLabels'
111+
update_verb: 'POST'
112+
- name: 'labelFingerprint'
113+
type: Fingerprint
114+
description: |
115+
The fingerprint used for optimistic locking of this resource. Used
116+
internally during updates.
117+
output: true
118+
update_url: 'projects/{{project}}/zones/{{zone}}/instantSnapshots/{{name}}/setLabels'
119+
update_verb: 'POST'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "google_compute_disk" "foo" {
2+
name = "{{index $.Vars "disk_name"}}"
3+
type = "pd-ssd"
4+
size = 10
5+
}
6+
7+
resource "google_compute_instant_snapshot" "{{$.PrimaryResourceId}}" {
8+
name = "{{index $.Vars "instance_name"}}"
9+
zone = "us-central1-a"
10+
source_disk = google_compute_disk.foo.self_link
11+
}

0 commit comments

Comments
 (0)