Skip to content

Commit 6a4252e

Browse files
Adding missing fields to vertexai.Endpoint resource (#12110) (#8619)
[upstream:ee5b3de20ce91c5cf5cffd417512a498ff16e09f] Signed-off-by: Modular Magician <[email protected]>
1 parent 8b5b1b7 commit 6a4252e

7 files changed

+1010
-49
lines changed

Diff for: .changelog/12110.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
vertexai: added `traffic_split`, `private_service_connect_config`, `predict_request_response_logging_config`, `dedicated_endpoint_enabled`, and `dedicated_endpoint_dns` fields to `google_vertex_ai_endpoint` resource
3+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
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+
member = "user:[email protected]"
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+
members = ["user:[email protected]", "user:[email protected]"]
299+
}
300+
`, context)
301+
}

Diff for: google-beta/services/vertexai/iam_vertex_endpoint_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestAccVertexAIEndpointIamPolicy(t *testing.T) {
9797
ImportStateVerify: true,
9898
},
9999
{
100-
Config: testAccVertexAIEndpointIamPolicy_emptyBinding(context),
100+
Config: testAccVertexAIEndpointIamPolicy_emptyBindingManual(context),
101101
},
102102
{
103103
ResourceName: "google_vertex_ai_endpoint_iam_policy.foo",
@@ -218,7 +218,7 @@ endpoint = google_vertex_ai_endpoint.endpoint.name
218218
`, context)
219219
}
220220

221-
func testAccVertexAIEndpointIamPolicy_emptyBinding(context map[string]interface{}) string {
221+
func testAccVertexAIEndpointIamPolicy_emptyBindingManual(context map[string]interface{}) string {
222222
return acctest.Nprintf(`
223223
resource "google_vertex_ai_endpoint" "endpoint" {
224224
name = "tf-test-endpoint-name%{random_suffix}"

0 commit comments

Comments
 (0)