@@ -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