|
| 1 | +// Copyright (c) HashiCorp, Inc. |
| 2 | +// SPDX-License-Identifier: MPL-2.0 |
| 3 | + |
| 4 | +// ---------------------------------------------------------------------------- |
| 5 | +// |
| 6 | +// *** AUTO GENERATED CODE *** Type: MMv1 *** |
| 7 | +// |
| 8 | +// ---------------------------------------------------------------------------- |
| 9 | +// |
| 10 | +// This file is automatically generated by Magic Modules and manual |
| 11 | +// changes will be clobbered when the file is regenerated. |
| 12 | +// |
| 13 | +// Please read more about how to change this file in |
| 14 | +// .github/CONTRIBUTING.md. |
| 15 | +// |
| 16 | +// ---------------------------------------------------------------------------- |
| 17 | + |
| 18 | +package vertexai_test |
| 19 | + |
| 20 | +import ( |
| 21 | + "fmt" |
| 22 | + "testing" |
| 23 | + |
| 24 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 25 | + |
| 26 | + "github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest" |
| 27 | + "github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar" |
| 28 | +) |
| 29 | + |
| 30 | +func TestAccVertexAIEndpointIamBindingGenerated(t *testing.T) { |
| 31 | + t.Parallel() |
| 32 | + |
| 33 | + context := map[string]interface{}{ |
| 34 | + "random_suffix": acctest.RandString(t, 10), |
| 35 | + "role": "roles/viewer", |
| 36 | + } |
| 37 | + |
| 38 | + acctest.VcrTest(t, resource.TestCase{ |
| 39 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 40 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 41 | + Steps: []resource.TestStep{ |
| 42 | + { |
| 43 | + Config: testAccVertexAIEndpointIamBinding_basicGenerated(context), |
| 44 | + }, |
| 45 | + { |
| 46 | + ResourceName: "google_vertex_ai_endpoint_iam_binding.foo", |
| 47 | + ImportStateId: fmt.Sprintf("projects/%s/locations/%s/endpoints/%s roles/viewer", envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), fmt.Sprintf("endpoint-name%s", context["random_suffix"])), |
| 48 | + ImportState: true, |
| 49 | + ImportStateVerify: true, |
| 50 | + }, |
| 51 | + { |
| 52 | + // Test Iam Binding update |
| 53 | + Config: testAccVertexAIEndpointIamBinding_updateGenerated(context), |
| 54 | + }, |
| 55 | + { |
| 56 | + ResourceName: "google_vertex_ai_endpoint_iam_binding.foo", |
| 57 | + ImportStateId: fmt.Sprintf("projects/%s/locations/%s/endpoints/%s roles/viewer", envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), fmt.Sprintf("endpoint-name%s", context["random_suffix"])), |
| 58 | + ImportState: true, |
| 59 | + ImportStateVerify: true, |
| 60 | + }, |
| 61 | + }, |
| 62 | + }) |
| 63 | +} |
| 64 | + |
| 65 | +func TestAccVertexAIEndpointIamMemberGenerated(t *testing.T) { |
| 66 | + t.Parallel() |
| 67 | + |
| 68 | + context := map[string]interface{}{ |
| 69 | + "random_suffix": acctest.RandString(t, 10), |
| 70 | + "role": "roles/viewer", |
| 71 | + } |
| 72 | + |
| 73 | + acctest.VcrTest(t, resource.TestCase{ |
| 74 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 75 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 76 | + Steps: []resource.TestStep{ |
| 77 | + { |
| 78 | + // Test Iam Member creation (no update for member, no need to test) |
| 79 | + Config: testAccVertexAIEndpointIamMember_basicGenerated(context), |
| 80 | + }, |
| 81 | + { |
| 82 | + ResourceName: "google_vertex_ai_endpoint_iam_member.foo", |
| 83 | + ImportStateId: fmt. Sprintf( "projects/%s/locations/%s/endpoints/%s roles/viewer user:[email protected]", envvar. GetTestProjectFromEnv(), envvar. GetTestRegionFromEnv(), fmt. Sprintf( "endpoint-name%s", context[ "random_suffix"])), |
| 84 | + ImportState: true, |
| 85 | + ImportStateVerify: true, |
| 86 | + }, |
| 87 | + }, |
| 88 | + }) |
| 89 | +} |
| 90 | + |
| 91 | +func TestAccVertexAIEndpointIamPolicyGenerated(t *testing.T) { |
| 92 | + t.Parallel() |
| 93 | + |
| 94 | + context := map[string]interface{}{ |
| 95 | + "random_suffix": acctest.RandString(t, 10), |
| 96 | + "role": "roles/viewer", |
| 97 | + } |
| 98 | + |
| 99 | + acctest.VcrTest(t, resource.TestCase{ |
| 100 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 101 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 102 | + Steps: []resource.TestStep{ |
| 103 | + { |
| 104 | + Config: testAccVertexAIEndpointIamPolicy_basicGenerated(context), |
| 105 | + Check: resource.TestCheckResourceAttrSet("data.google_vertex_ai_endpoint_iam_policy.foo", "policy_data"), |
| 106 | + }, |
| 107 | + { |
| 108 | + ResourceName: "google_vertex_ai_endpoint_iam_policy.foo", |
| 109 | + ImportStateId: fmt.Sprintf("projects/%s/locations/%s/endpoints/%s", envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), fmt.Sprintf("endpoint-name%s", context["random_suffix"])), |
| 110 | + ImportState: true, |
| 111 | + ImportStateVerify: true, |
| 112 | + }, |
| 113 | + { |
| 114 | + Config: testAccVertexAIEndpointIamPolicy_emptyBinding(context), |
| 115 | + }, |
| 116 | + { |
| 117 | + ResourceName: "google_vertex_ai_endpoint_iam_policy.foo", |
| 118 | + ImportStateId: fmt.Sprintf("projects/%s/locations/%s/endpoints/%s", envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), fmt.Sprintf("endpoint-name%s", context["random_suffix"])), |
| 119 | + ImportState: true, |
| 120 | + ImportStateVerify: true, |
| 121 | + }, |
| 122 | + }, |
| 123 | + }) |
| 124 | +} |
| 125 | + |
| 126 | +func testAccVertexAIEndpointIamMember_basicGenerated(context map[string]interface{}) string { |
| 127 | + return acctest.Nprintf(` |
| 128 | +resource "google_vertex_ai_endpoint" "endpoint" { |
| 129 | + name = "endpoint-name%{random_suffix}" |
| 130 | + display_name = "sample-endpoint" |
| 131 | + description = "A sample vertex endpoint" |
| 132 | + location = "us-central1" |
| 133 | + region = "us-central1" |
| 134 | + labels = { |
| 135 | + label-one = "value-one" |
| 136 | + } |
| 137 | + private_service_connect_config { |
| 138 | + enable_private_service_connect = true |
| 139 | + project_allowlist = [ |
| 140 | + "${data.google_project.project.project_id}" |
| 141 | + ] |
| 142 | + enable_secure_private_service_connect = false |
| 143 | + } |
| 144 | +} |
| 145 | +
|
| 146 | +data "google_project" "project" {} |
| 147 | +
|
| 148 | +resource "google_vertex_ai_endpoint_iam_member" "foo" { |
| 149 | + project = google_vertex_ai_endpoint.endpoint.project |
| 150 | + location = google_vertex_ai_endpoint.endpoint.location |
| 151 | + endpoint = google_vertex_ai_endpoint.endpoint.name |
| 152 | + role = "%{role}" |
| 153 | + |
| 154 | +} |
| 155 | +`, context) |
| 156 | +} |
| 157 | + |
| 158 | +func testAccVertexAIEndpointIamPolicy_basicGenerated(context map[string]interface{}) string { |
| 159 | + return acctest.Nprintf(` |
| 160 | +resource "google_vertex_ai_endpoint" "endpoint" { |
| 161 | + name = "endpoint-name%{random_suffix}" |
| 162 | + display_name = "sample-endpoint" |
| 163 | + description = "A sample vertex endpoint" |
| 164 | + location = "us-central1" |
| 165 | + region = "us-central1" |
| 166 | + labels = { |
| 167 | + label-one = "value-one" |
| 168 | + } |
| 169 | + private_service_connect_config { |
| 170 | + enable_private_service_connect = true |
| 171 | + project_allowlist = [ |
| 172 | + "${data.google_project.project.project_id}" |
| 173 | + ] |
| 174 | + enable_secure_private_service_connect = false |
| 175 | + } |
| 176 | +} |
| 177 | +
|
| 178 | +data "google_project" "project" {} |
| 179 | +
|
| 180 | +data "google_iam_policy" "foo" { |
| 181 | + binding { |
| 182 | + role = "%{role}" |
| 183 | + members = ["user:[email protected]"] |
| 184 | + } |
| 185 | +} |
| 186 | +
|
| 187 | +resource "google_vertex_ai_endpoint_iam_policy" "foo" { |
| 188 | + project = google_vertex_ai_endpoint.endpoint.project |
| 189 | + location = google_vertex_ai_endpoint.endpoint.location |
| 190 | + endpoint = google_vertex_ai_endpoint.endpoint.name |
| 191 | + policy_data = data.google_iam_policy.foo.policy_data |
| 192 | +} |
| 193 | +
|
| 194 | +data "google_vertex_ai_endpoint_iam_policy" "foo" { |
| 195 | + project = google_vertex_ai_endpoint.endpoint.project |
| 196 | + location = google_vertex_ai_endpoint.endpoint.location |
| 197 | + endpoint = google_vertex_ai_endpoint.endpoint.name |
| 198 | + depends_on = [ |
| 199 | + google_vertex_ai_endpoint_iam_policy.foo |
| 200 | + ] |
| 201 | +} |
| 202 | +`, context) |
| 203 | +} |
| 204 | + |
| 205 | +func testAccVertexAIEndpointIamPolicy_emptyBinding(context map[string]interface{}) string { |
| 206 | + return acctest.Nprintf(` |
| 207 | +resource "google_vertex_ai_endpoint" "endpoint" { |
| 208 | + name = "endpoint-name%{random_suffix}" |
| 209 | + display_name = "sample-endpoint" |
| 210 | + description = "A sample vertex endpoint" |
| 211 | + location = "us-central1" |
| 212 | + region = "us-central1" |
| 213 | + labels = { |
| 214 | + label-one = "value-one" |
| 215 | + } |
| 216 | + private_service_connect_config { |
| 217 | + enable_private_service_connect = true |
| 218 | + project_allowlist = [ |
| 219 | + "${data.google_project.project.project_id}" |
| 220 | + ] |
| 221 | + enable_secure_private_service_connect = false |
| 222 | + } |
| 223 | +} |
| 224 | +
|
| 225 | +data "google_project" "project" {} |
| 226 | +
|
| 227 | +data "google_iam_policy" "foo" { |
| 228 | +} |
| 229 | +
|
| 230 | +resource "google_vertex_ai_endpoint_iam_policy" "foo" { |
| 231 | + project = google_vertex_ai_endpoint.endpoint.project |
| 232 | + location = google_vertex_ai_endpoint.endpoint.location |
| 233 | + endpoint = google_vertex_ai_endpoint.endpoint.name |
| 234 | + policy_data = data.google_iam_policy.foo.policy_data |
| 235 | +} |
| 236 | +`, context) |
| 237 | +} |
| 238 | + |
| 239 | +func testAccVertexAIEndpointIamBinding_basicGenerated(context map[string]interface{}) string { |
| 240 | + return acctest.Nprintf(` |
| 241 | +resource "google_vertex_ai_endpoint" "endpoint" { |
| 242 | + name = "endpoint-name%{random_suffix}" |
| 243 | + display_name = "sample-endpoint" |
| 244 | + description = "A sample vertex endpoint" |
| 245 | + location = "us-central1" |
| 246 | + region = "us-central1" |
| 247 | + labels = { |
| 248 | + label-one = "value-one" |
| 249 | + } |
| 250 | + private_service_connect_config { |
| 251 | + enable_private_service_connect = true |
| 252 | + project_allowlist = [ |
| 253 | + "${data.google_project.project.project_id}" |
| 254 | + ] |
| 255 | + enable_secure_private_service_connect = false |
| 256 | + } |
| 257 | +} |
| 258 | +
|
| 259 | +data "google_project" "project" {} |
| 260 | +
|
| 261 | +resource "google_vertex_ai_endpoint_iam_binding" "foo" { |
| 262 | + project = google_vertex_ai_endpoint.endpoint.project |
| 263 | + location = google_vertex_ai_endpoint.endpoint.location |
| 264 | + endpoint = google_vertex_ai_endpoint.endpoint.name |
| 265 | + role = "%{role}" |
| 266 | + members = ["user:[email protected]"] |
| 267 | +} |
| 268 | +`, context) |
| 269 | +} |
| 270 | + |
| 271 | +func testAccVertexAIEndpointIamBinding_updateGenerated(context map[string]interface{}) string { |
| 272 | + return acctest.Nprintf(` |
| 273 | +resource "google_vertex_ai_endpoint" "endpoint" { |
| 274 | + name = "endpoint-name%{random_suffix}" |
| 275 | + display_name = "sample-endpoint" |
| 276 | + description = "A sample vertex endpoint" |
| 277 | + location = "us-central1" |
| 278 | + region = "us-central1" |
| 279 | + labels = { |
| 280 | + label-one = "value-one" |
| 281 | + } |
| 282 | + private_service_connect_config { |
| 283 | + enable_private_service_connect = true |
| 284 | + project_allowlist = [ |
| 285 | + "${data.google_project.project.project_id}" |
| 286 | + ] |
| 287 | + enable_secure_private_service_connect = false |
| 288 | + } |
| 289 | +} |
| 290 | +
|
| 291 | +data "google_project" "project" {} |
| 292 | +
|
| 293 | +resource "google_vertex_ai_endpoint_iam_binding" "foo" { |
| 294 | + project = google_vertex_ai_endpoint.endpoint.project |
| 295 | + location = google_vertex_ai_endpoint.endpoint.location |
| 296 | + endpoint = google_vertex_ai_endpoint.endpoint.name |
| 297 | + role = "%{role}" |
| 298 | + |
| 299 | +} |
| 300 | +`, context) |
| 301 | +} |
0 commit comments