Skip to content

Commit 546c24c

Browse files
axelkossektrodge
andauthored
Add resource_manager_tags support to Region Backend Service api (#14837)
Co-authored-by: Thomas Rodgers <[email protected]>
1 parent ff818d3 commit 546c24c

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

mmv1/products/compute/RegionBackendService.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,3 +1544,19 @@ properties:
15441544
description: |
15451545
The name of the VM instance of the leader network endpoint. The instance must
15461546
already be attached to the NEG specified in the haPolicy.leader.backendGroup.
1547+
- name: 'params'
1548+
type: NestedObject
1549+
ignore_read: true
1550+
immutable: true
1551+
description: |
1552+
Additional params passed with the request, but not persisted as part of resource payload
1553+
properties:
1554+
- name: 'resourceManagerTags'
1555+
type: KeyValuePairs
1556+
description: |
1557+
Resource manager tags to be bound to the region backend service. Tag keys and values have the
1558+
same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id},
1559+
and values are in the format tagValues/456.
1560+
api_name: resourceManagerTags
1561+
ignore_read: true
1562+
immutable: true

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

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

88
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
99
"github.com/hashicorp/terraform-provider-google/google/acctest"
10+
"github.com/hashicorp/terraform-provider-google/google/envvar"
1011
)
1112

1213
func TestAccComputeRegionBackendService_basic(t *testing.T) {
@@ -756,6 +757,35 @@ func TestAccComputeRegionBackendService_withDynamicBackendCount(t *testing.T) {
756757
})
757758
}
758759

760+
func TestAccComputeRegionBackendService_withTags(t *testing.T) {
761+
t.Parallel()
762+
763+
org := envvar.GetTestOrgFromEnv(t)
764+
765+
serviceName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
766+
checkName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
767+
tagKeyResult := acctest.BootstrapSharedTestTagKeyDetails(t, "crm-rbs-tagkey", "organizations/"+org, make(map[string]interface{}))
768+
sharedTagkey,_ := tagKeyResult["shared_tag_key"]
769+
tagValueResult := acctest.BootstrapSharedTestTagValueDetails(t, "crm-rbs-tagvalue", sharedTagkey, org)
770+
771+
acctest.VcrTest(t, resource.TestCase{
772+
PreCheck: func() { acctest.AccTestPreCheck(t) },
773+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
774+
CheckDestroy: testAccCheckComputeRegionBackendServiceDestroyProducer(t),
775+
Steps: []resource.TestStep{
776+
{
777+
Config: testAccComputeRegionBackendService_withTags(serviceName, checkName, tagKeyResult["name"], tagValueResult["name"]),
778+
},
779+
{
780+
ResourceName: "google_compute_region_backend_service.foobar",
781+
ImportState: true,
782+
ImportStateVerify: true,
783+
ImportStateVerifyIgnore: []string{"params"},
784+
},
785+
},
786+
})
787+
}
788+
759789
func testAccComputeRegionBackendService_withDynamicBackendCount(serviceName, netName, hcName, igName string) string {
760790
return fmt.Sprintf(`
761791
locals {
@@ -1770,3 +1800,28 @@ resource "google_compute_region_health_check" "health_check" {
17701800
}
17711801
`, serviceName, checkName)
17721802
}
1803+
1804+
func testAccComputeRegionBackendService_withTags(serviceName, checkName string, tagKey string, tagValue string) string {
1805+
return fmt.Sprintf(`
1806+
resource "google_compute_region_backend_service" "foobar" {
1807+
name = "%s"
1808+
health_checks = [google_compute_health_check.zero.self_link]
1809+
region = "us-central1"
1810+
params {
1811+
resource_manager_tags = {
1812+
"%s" = "%s"
1813+
}
1814+
}
1815+
}
1816+
1817+
resource "google_compute_health_check" "zero" {
1818+
name = "%s"
1819+
check_interval_sec = 1
1820+
timeout_sec = 1
1821+
1822+
tcp_health_check {
1823+
port = "80"
1824+
}
1825+
}
1826+
`, serviceName, tagKey, tagValue, checkName)
1827+
}

0 commit comments

Comments
 (0)