Skip to content

Commit 200a1ec

Browse files
Interconnect resource manager tags at creation (#15831)
1 parent e025834 commit 200a1ec

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

mmv1/products/compute/Interconnect.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ properties:
127127
interconnect and no BGP routes are exchanged over it. By default, the status is set to true.
128128
send_empty_value: true
129129
default_value: true
130+
- name: 'params'
131+
type: NestedObject
132+
ignore_read: true
133+
immutable: true
134+
description: |
135+
Additional params passed with the request, but not persisted as part of resource payload
136+
properties:
137+
- name: 'resourceManagerTags'
138+
type: KeyValuePairs
139+
description: |
140+
Resource manager tags to be bound to the interconnect. Tag keys and values have the
141+
same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id},
142+
and values are in the format tagValues/456.
143+
api_name: resourceManagerTags
144+
ignore_read: true
130145
- name: 'nocContactEmail'
131146
type: String
132147
description: |

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
77

88
"github.com/hashicorp/terraform-provider-google/google/acctest"
9+
"github.com/hashicorp/terraform-provider-google/google/envvar"
910
)
1011

1112
func TestAccComputeInterconnect_computeInterconnectMacsecTest(t *testing.T) {
@@ -94,3 +95,63 @@ resource "google_compute_interconnect" "example-interconnect" {
9495
}
9596
`, context)
9697
}
98+
99+
func TestAccComputeInterconnect_resourceManagerTags(t *testing.T) {
100+
t.Parallel()
101+
org := envvar.GetTestOrgFromEnv(t)
102+
103+
tagKeyResult := acctest.BootstrapSharedTestTagKeyDetails(t, "crm-interconnects-tagkey", "organizations/"+org, make(map[string]interface{}))
104+
sharedTagkey, _ := tagKeyResult["shared_tag_key"]
105+
tagValueResult := acctest.BootstrapSharedTestTagValueDetails(t, "crm-interconnects-tagvalue", sharedTagkey, org)
106+
107+
context := map[string]interface{}{
108+
"tag_key_id": tagKeyResult["name"],
109+
"tag_value_id": tagValueResult["name"],
110+
"random_suffix": acctest.RandString(t, 10),
111+
}
112+
113+
acctest.VcrTest(t, resource.TestCase{
114+
PreCheck: func() { acctest.AccTestPreCheck(t) },
115+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
116+
CheckDestroy: testAccCheckComputeInterconnectDestroyProducer(t),
117+
Steps: []resource.TestStep{
118+
{
119+
Config: testAccComputeInterconnect_computeInterconnectParams(context),
120+
},
121+
{
122+
ResourceName: "google_compute_interconnect.example-interconnect",
123+
ImportState: true,
124+
ImportStateVerify: true,
125+
ImportStateVerifyIgnore: []string{"labels", "location", "terraform_labels", "params"},
126+
},
127+
},
128+
})
129+
}
130+
131+
func testAccComputeInterconnect_computeInterconnectParams(context map[string]interface{}) string {
132+
return acctest.Nprintf(`
133+
data "google_project" "project" {}
134+
135+
resource "google_compute_interconnect" "example-interconnect" {
136+
name = "tf-test-example-interconnect%{random_suffix}"
137+
customer_name = "internal_customer" # Special customer only available for Google testing.
138+
interconnect_type = "DEDICATED"
139+
link_type = "LINK_TYPE_ETHERNET_100G_LR"
140+
location = "https://www.googleapis.com/compute/v1/projects/${data.google_project.project.name}/global/interconnectLocations/z2z-us-east4-zone1-lciadl-z" # Special location only available for Google testing.
141+
requested_link_count = 1
142+
admin_enabled = true
143+
description = "example description"
144+
macsec_enabled = false
145+
noc_contact_email = "[email protected]"
146+
requested_features = ["IF_MACSEC"]
147+
labels = {
148+
mykey = "myvalue"
149+
}
150+
params {
151+
resource_manager_tags = {
152+
"%{tag_key_id}" = "%{tag_value_id}"
153+
}
154+
}
155+
}
156+
`, context)
157+
}

0 commit comments

Comments
 (0)