From 9d89e04440adaf973664b158eb1e8f762d79ce3f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 10:22:14 +0000 Subject: [PATCH] Support resource_manager_tags for Interconnect in GA This change adds support for `resource_manager_tags` within the `params` block for the `google_compute_interconnect` resource. It follows the pattern used in `google_compute_router`. - Updates `mmv1/products/compute/Interconnect.yaml` to include the `params` field. - Adds a new handwritten test template `mmv1/third_party/terraform/services/compute/resource_compute_interconnect_resource_manager_tags_test.go.tmpl` to verify the functionality. - Adds an example template `mmv1/templates/terraform/examples/compute_interconnect_resource_manager_tags_test.tf.tmpl` for documentation/reference. --- mmv1/products/compute/Interconnect.yaml | 21 ++++++ ...connect_resource_manager_tags_test.tf.tmpl | 23 +++++++ ...connect_resource_manager_tags_test.go.tmpl | 68 +++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 mmv1/templates/terraform/examples/compute_interconnect_resource_manager_tags_test.tf.tmpl create mode 100644 mmv1/third_party/terraform/services/compute/resource_compute_interconnect_resource_manager_tags_test.go.tmpl diff --git a/mmv1/products/compute/Interconnect.yaml b/mmv1/products/compute/Interconnect.yaml index 0943605e9a7d..5e73a2c158d3 100644 --- a/mmv1/products/compute/Interconnect.yaml +++ b/mmv1/products/compute/Interconnect.yaml @@ -54,6 +54,12 @@ examples: vars: interconnect_name: 'example-interconnect' exclude_docs: true + - name: 'compute_interconnect_resource_manager_tags_test' + primary_resource_id: 'example-interconnect' + vars: + interconnect_name: 'example-interconnect' + exclude_docs: true + exclude_test: true parameters: properties: - name: 'description' @@ -434,6 +440,21 @@ properties: is_set: true item_type: type: String + - name: 'params' + type: NestedObject + ignore_read: true + immutable: true + description: | + Additional params passed with the request, but not persisted as part of resource payload + properties: + - name: 'resourceManagerTags' + type: KeyValuePairs + description: | + Resource manager tags to be bound to the interconnect. Tag keys and values have the + same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, + and values are in the format tagValues/456. + api_name: resourceManagerTags + ignore_read: true - name: 'aaiEnabled' type: Boolean description: | diff --git a/mmv1/templates/terraform/examples/compute_interconnect_resource_manager_tags_test.tf.tmpl b/mmv1/templates/terraform/examples/compute_interconnect_resource_manager_tags_test.tf.tmpl new file mode 100644 index 000000000000..0b82332b6efd --- /dev/null +++ b/mmv1/templates/terraform/examples/compute_interconnect_resource_manager_tags_test.tf.tmpl @@ -0,0 +1,23 @@ +data "google_project" "project" {} + +resource "google_compute_interconnect" "{{$.PrimaryResourceId}}" { + name = "{{index $.Vars "interconnect_name"}}" + customer_name = "internal_customer" # Special customer only available for Google testing. + interconnect_type = "DEDICATED" + link_type = "LINK_TYPE_ETHERNET_10G_LR" + location = "https://www.googleapis.com/compute/v1/projects/${data.google_project.project.project_id}/global/interconnectLocations/z2z-us-east4-zone1-lciadl-a" # Special location only available for Google testing. + requested_link_count = 1 + admin_enabled = true + description = "example description" + macsec_enabled = false + noc_contact_email = "user@example.com" + requested_features = [] + labels = { + mykey = "myvalue" + } + params { + resource_manager_tags = { + "{{index $.Vars "tag_key_id"}}" = "{{index $.Vars "tag_value_id"}}" + } + } +} diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_interconnect_resource_manager_tags_test.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_interconnect_resource_manager_tags_test.go.tmpl new file mode 100644 index 000000000000..c3bfc039c4e2 --- /dev/null +++ b/mmv1/third_party/terraform/services/compute/resource_compute_interconnect_resource_manager_tags_test.go.tmpl @@ -0,0 +1,68 @@ +package compute_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-provider-google/google/acctest" + "github.com/hashicorp/terraform-provider-google/google/envvar" +) + +func TestAccComputeInterconnect_resourceManagerTags(t *testing.T) { + t.Parallel() + org := envvar.GetTestOrgFromEnv(t) + + suffixName := acctest.RandString(t, 10) + tagKeyResult := acctest.BootstrapSharedTestTagKeyDetails(t, "crm-interconnect-tagkey", "organizations/"+org, make(map[string]interface{})) + sharedTagkey,_ := tagKeyResult["shared_tag_key"] + tagValueResult := acctest.BootstrapSharedTestTagValueDetails(t, "crm-interconnect-tagvalue", sharedTagkey, org) + interconnectName := fmt.Sprintf("tf-test-interconnect-resource-manager-tags-%s", suffixName) + context := map[string]interface{}{ + "interconnect_name": interconnectName, + "tag_key_id": tagKeyResult["name"], + "tag_value_id": tagValueResult["name"], + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckComputeInterconnectDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeInterconnect_resourceManagerTags(context), + }, + { + ResourceName: "google_compute_interconnect.foobar", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"params"}, + }, + }, + }) +} + +func testAccComputeInterconnect_resourceManagerTags(context map[string]interface{}) string { + return acctest.Nprintf(` + data "google_project" "project" {} + + resource "google_compute_interconnect" "foobar" { + name = "%{interconnect_name}" + customer_name = "internal_customer" # Special customer only available for Google testing. + interconnect_type = "DEDICATED" + link_type = "LINK_TYPE_ETHERNET_10G_LR" + location = "https://www.googleapis.com/compute/v1/projects/${data.google_project.project.project_id}/global/interconnectLocations/z2z-us-east4-zone1-lciadl-a" # Special location only available for Google testing. + requested_link_count = 1 + admin_enabled = true + description = "example description" + macsec_enabled = false + noc_contact_email = "user@example.com" + requested_features = [] + params { + resource_manager_tags = { + "%{tag_key_id}" = "%{tag_value_id}" + } + } + } + `, context) +}