Skip to content

Commit 84b342b

Browse files
authored
Feature gap: Add snapshotType to Snapshot (#15824)
Signed-off-by: Cezary Sobczak <[email protected]>
1 parent 92b1068 commit 84b342b

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

mmv1/products/compute/Snapshot.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,10 @@ properties:
263263
update_url: 'projects/{{project}}/global/snapshots/{{name}}/setLabels'
264264
update_verb: 'POST'
265265
key_expander: ''
266+
- name: 'snapshotType'
267+
type: Enum
268+
description: |
269+
Indicates the type of the snapshot.
270+
enum_values:
271+
- 'ARCHIVE'
272+
- 'STANDARD'

mmv1/third_party/terraform/services/compute/resource_compute_snapshot_test.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,72 @@ resource "google_compute_snapshot" "foobar" {
134134
}
135135
`, diskName, kmsKeyName, diskName, kmsKeyName, snapshotName, kmsKeyName)
136136
}
137+
138+
func TestAccComputeSnapshot_snapshotType(t *testing.T) {
139+
t.Parallel()
140+
141+
randomSuffix := acctest.RandString(t, 10)
142+
context1 := map[string]interface{}{
143+
"random_suffix": randomSuffix,
144+
"snapshot_type": "ARCHIVE",
145+
}
146+
147+
context2 := map[string]interface{}{
148+
"random_suffix": randomSuffix,
149+
"snapshot_type": "STANDARD",
150+
}
151+
152+
acctest.VcrTest(t, resource.TestCase{
153+
PreCheck: func() { acctest.AccTestPreCheck(t) },
154+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
155+
CheckDestroy: testAccCheckComputeSnapshotDestroyProducer(t),
156+
Steps: []resource.TestStep{
157+
{
158+
Config: testAccComputeSnapshot_snapshotType(context1),
159+
},
160+
{
161+
ResourceName: "google_compute_snapshot.snapshot",
162+
ImportState: true,
163+
ImportStateVerify: true,
164+
ImportStateVerifyIgnore: []string{"labels", "snapshot_encryption_key.0.raw_key", "snapshot_encryption_key.0.rsa_encrypted_key", "source_disk", "source_disk_encryption_key", "terraform_labels", "zone"},
165+
},
166+
{
167+
Config: testAccComputeSnapshot_snapshotType(context2),
168+
},
169+
{
170+
ResourceName: "google_compute_snapshot.snapshot",
171+
ImportState: true,
172+
ImportStateVerify: true,
173+
ImportStateVerifyIgnore: []string{"labels", "snapshot_encryption_key.0.raw_key", "snapshot_encryption_key.0.rsa_encrypted_key", "source_disk", "source_disk_encryption_key", "terraform_labels", "zone"},
174+
},
175+
},
176+
})
177+
}
178+
179+
func testAccComputeSnapshot_snapshotType(context map[string]interface{}) string {
180+
return acctest.Nprintf(`
181+
resource "google_compute_snapshot" "snapshot" {
182+
name = "tf-test-my-snapshot%{random_suffix}"
183+
source_disk = google_compute_disk.persistent.id
184+
zone = "us-central1-a"
185+
labels = {
186+
my_label = "value"
187+
}
188+
storage_locations = ["us-central1"]
189+
snapshot_type = "%{snapshot_type}"
190+
}
191+
192+
data "google_compute_image" "debian" {
193+
family = "debian-11"
194+
project = "debian-cloud"
195+
}
196+
197+
resource "google_compute_disk" "persistent" {
198+
name = "tf-test-debian-disk%{random_suffix}"
199+
image = data.google_compute_image.debian.self_link
200+
size = 10
201+
type = "pd-ssd"
202+
zone = "us-central1-a"
203+
}
204+
`, context)
205+
}

0 commit comments

Comments
 (0)