|
6 | 6 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
7 | 7 |
|
8 | 8 | "github.com/hashicorp/terraform-provider-google/google/acctest" |
| 9 | + "github.com/hashicorp/terraform-provider-google/google/envvar" |
9 | 10 | ) |
10 | 11 |
|
11 | 12 | func TestAccComputeInterconnect_computeInterconnectMacsecTest(t *testing.T) { |
@@ -94,3 +95,63 @@ resource "google_compute_interconnect" "example-interconnect" { |
94 | 95 | } |
95 | 96 | `, context) |
96 | 97 | } |
| 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