Skip to content

Commit c711135

Browse files
compute: add resource_manager_tags to google_compute_instant_snapshot
1 parent 4a20a4d commit c711135

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

mmv1/products/compute/InstantSnapshot.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,18 @@ properties:
119119
output: true
120120
update_url: 'projects/{{project}}/zones/{{zone}}/instantSnapshots/{{name}}/setLabels'
121121
update_verb: 'POST'
122+
- name: 'params'
123+
type: NestedObject
124+
ignore_read: true
125+
immutable: true
126+
description: |
127+
Additional params passed with the request, but not persisted as part of resource payload
128+
properties:
129+
- name: 'resourceManagerTags'
130+
type: KeyValuePairs
131+
description: |
132+
Resource manager tags to be bound to the instant snapshot. Tag keys and values have the
133+
same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id},
134+
and values are in the format tagValues/456.
135+
api_name: resourceManagerTags
136+
ignore_read: true

mmv1/third_party/terraform/services/compute/resource_compute_instant_snapshot_test.go.tmpl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,52 @@ resource "google_compute_instant_snapshot" "foobar" {
157157
}
158158
`, context)
159159
}
160+
161+
func TestAccComputeInstantSnapshot_resourceManagerTags(t *testing.T) {
162+
t.Parallel()
163+
164+
org := envvar.GetTestOrgFromEnv(t)
165+
suffix := acctest.RandString(t, 10)
166+
tagKeyResult := acctest.BootstrapSharedTestTagKeyDetails(t, "crm-instant-snapshots-tagkey", "organizations/"+org, make(map[string]interface{}))
167+
sharedTagKey, _ := tagKeyResult["shared_tag_key"]
168+
tagValueResult := acctest.BootstrapSharedTestTagValueDetails(t, "crm-instant-snapshots-tagvalue", sharedTagKey, org)
169+
170+
context := map[string]interface{}{
171+
"random_suffix": suffix,
172+
"tag_key_id": tagKeyResult["name"],
173+
"tag_value_id": tagValueResult["name"],
174+
}
175+
176+
acctest.VcrTest(t, resource.TestCase{
177+
PreCheck: func() { acctest.AccTestPreCheck(t) },
178+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
179+
CheckDestroy: testAccCheckComputeInstantSnapshotDestroyProducer(t),
180+
Steps: []resource.TestStep{
181+
{
182+
Config: testAccComputeInstantSnapshot_resourceManagerTags(context),
183+
},
184+
},
185+
})
186+
}
187+
188+
func testAccComputeInstantSnapshot_resourceManagerTags(context map[string]interface{}) string {
189+
return acctest.Nprintf(`
190+
resource "google_compute_disk" "disk" {
191+
name = "tf-test-disk-%{random_suffix}"
192+
type = "pd-standard"
193+
zone = "us-central1-a"
194+
size = 10
195+
}
196+
197+
resource "google_compute_instant_snapshot" "foobar" {
198+
name = "tf-test-instant-snapshot-%{random_suffix}"
199+
source_disk = google_compute_disk.disk.self_link
200+
zone = google_compute_disk.disk.zone
201+
params {
202+
resource_manager_tags = {
203+
"%{tag_key_id}" = "%{tag_value_id}"
204+
}
205+
}
206+
}
207+
`, context)
208+
}

0 commit comments

Comments
 (0)