Skip to content

Commit b0e28ef

Browse files
compute: add params.resourceManagerTags to google_compute_reservation
Adds an input-only, ForceNew params.resource_manager_tags map field to google_compute_reservation so IAM resource manager tags can be bound at reservation creation. Mirrors the pattern from #14119 (Network).
1 parent ef8fcbf commit b0e28ef

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

mmv1/products/compute/Reservation.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,3 +553,18 @@ properties:
553553
description: |
554554
The number of reservation blocks that are degraded.
555555
output: true
556+
- name: 'params'
557+
type: NestedObject
558+
ignore_read: true
559+
immutable: true
560+
description: |
561+
Additional params passed with the request, but not persisted as part of resource payload
562+
properties:
563+
- name: 'resourceManagerTags'
564+
type: KeyValuePairs
565+
description: |
566+
Resource manager tags to be bound to the reservation. Tag keys and values have the
567+
same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id},
568+
and values are in the format tagValues/456.
569+
api_name: resourceManagerTags
570+
ignore_read: true

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1010
"github.com/hashicorp/terraform-provider-google/google/acctest"
11+
"github.com/hashicorp/terraform-provider-google/google/envvar"
1112
)
1213

1314
func TestAccComputeReservation_update(t *testing.T) {
@@ -174,3 +175,54 @@ resource "google_compute_reservation" "reservation" {
174175
}
175176
`, reservationName, time, duration)
176177
}
178+
179+
// Validates that params.resource_manager_tags is accepted at creation (input-only, ForceNew).
180+
func TestAccComputeReservation_resourceManagerTags(t *testing.T) {
181+
t.Parallel()
182+
183+
org := envvar.GetTestOrgFromEnv(t)
184+
suffixName := acctest.RandString(t, 10)
185+
tagKeyResult := acctest.BootstrapSharedTestTagKeyDetails(t, "crm-reservations-tagkey", "organizations/"+org, make(map[string]interface{}))
186+
sharedTagkey, _ := tagKeyResult["shared_tag_key"]
187+
tagValueResult := acctest.BootstrapSharedTestTagValueDetails(t, "crm-reservations-tagvalue", sharedTagkey, org)
188+
189+
context := map[string]interface{}{
190+
"reservation_name": fmt.Sprintf("tf-test-reservation-rmt-%s", suffixName),
191+
"tag_key_id": tagKeyResult["name"],
192+
"tag_value_id": tagValueResult["name"],
193+
}
194+
195+
acctest.VcrTest(t, resource.TestCase{
196+
PreCheck: func() { acctest.AccTestPreCheck(t) },
197+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
198+
CheckDestroy: testAccCheckComputeReservationDestroyProducer(t),
199+
Steps: []resource.TestStep{
200+
{
201+
Config: testAccComputeReservation_resourceManagerTags(context),
202+
},
203+
},
204+
})
205+
}
206+
207+
func testAccComputeReservation_resourceManagerTags(context map[string]interface{}) string {
208+
return acctest.Nprintf(`
209+
resource "google_compute_reservation" "reservation" {
210+
name = "%{reservation_name}"
211+
zone = "us-central1-a"
212+
213+
specific_reservation {
214+
count = 1
215+
instance_properties {
216+
min_cpu_platform = "Intel Cascade Lake"
217+
machine_type = "n2-standard-2"
218+
}
219+
}
220+
221+
params {
222+
resource_manager_tags = {
223+
"%{tag_key_id}" = "%{tag_value_id}"
224+
}
225+
}
226+
}
227+
`, context)
228+
}

0 commit comments

Comments
 (0)