Skip to content

Commit ec0c7a7

Browse files
LucaPreteLuca Prete
andauthored
Add PSC support to google_vertex_ai_endpoint_with_model_garden_deployment (#15178)
Co-authored-by: Luca Prete <[email protected]>
1 parent f63dbbf commit ec0c7a7

File tree

4 files changed

+221
-0
lines changed

4 files changed

+221
-0
lines changed

mmv1/products/vertexai/EndpointWithModelGardenDeployment.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ examples:
8787
ignore_read_extra:
8888
- "project"
8989
exclude_test: true # handwritten test required since resource does not support import
90+
- name: "vertex_ai_deploy_psc_endpoint"
91+
primary_resource_id: "deploy"
92+
vars:
93+
project: "vertex-ai"
94+
publisher_model_name: "publisher_model_name"
95+
ignore_read_extra:
96+
- "project"
97+
exclude_test: true # handwritten test required since resource does not support import
98+
- name: "vertex_ai_deploy_psc_endpoint_automated"
99+
primary_resource_id: "deploy"
100+
vars:
101+
project: "vertex-ai"
102+
publisher_model_name: "publisher_model_name"
103+
ignore_read_extra:
104+
- "project"
105+
exclude_test: true # handwritten test required since resource does not support import
90106
parameters:
91107
- name: location
92108
type: String
@@ -845,6 +861,71 @@ properties:
845861
performance and reliability. Note: Once you enabled dedicated endpoint,
846862
you won't be able to send request to the shared DNS
847863
{region}-aiplatform.googleapis.com. The limitations will be removed soon.
864+
- name: privateServiceConnectConfig
865+
type: NestedObject
866+
description: The configuration for Private Service Connect (PSC).
867+
immutable: true
868+
properties:
869+
- name: enablePrivateServiceConnect
870+
type: Boolean
871+
description: |-
872+
Required. If true, expose the IndexEndpoint via private service connect.
873+
required: true
874+
immutable: true
875+
- name: projectAllowlist
876+
type: Array
877+
immutable: true
878+
description: |-
879+
A list of Projects from which the forwarding rule will target the service attachment.
880+
item_type:
881+
type: String
882+
- name: pscAutomationConfigs
883+
type: NestedObject
884+
description: PSC config that is used to automatically create PSC endpoints in the user projects.
885+
immutable: true
886+
properties:
887+
- name: projectId
888+
type: String
889+
immutable: true
890+
description: Required. Project id used to create forwarding rule.
891+
required: true
892+
- name: network
893+
type: String
894+
immutable: true
895+
description: |-
896+
Required. The full name of the Google Compute Engine network.
897+
Format: projects/{project}/global/networks/{network}.
898+
required: true
899+
- name: ipAddress
900+
type: String
901+
description: |-
902+
Output only. IP address rule created by the PSC service automation.
903+
output: true
904+
- name: forwardingRule
905+
type: String
906+
description: |-
907+
Output only. Forwarding rule created by the PSC service automation.
908+
output: true
909+
- name: state
910+
type: Enum
911+
description: |-
912+
Output only. The state of the PSC service automation.
913+
output: true
914+
enum_values:
915+
- 'PSC_AUTOMATION_STATE_UNSPECIFIED'
916+
- 'PSC_AUTOMATION_STATE_SUCCESSFUL'
917+
- 'PSC_AUTOMATION_STATE_FAILED'
918+
- name: errorMessage
919+
type: String
920+
description: |-
921+
Output only. Error message if the PSC service automation failed.
922+
output: true
923+
- name: serviceAttachment
924+
type: String
925+
description: |-
926+
Output only. The name of the generated service attachment resource.
927+
This is only populated if the endpoint is deployed with PrivateServiceConnect.
928+
output: true
848929
- name: deployConfig
849930
type: NestedObject
850931
description: The deploy config to use for the deployment.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "google_vertex_ai_endpoint_with_model_garden_deployment" "{{$.PrimaryResourceId}}" {
2+
publisher_model_name = "publishers/google/models/paligemma@paligemma-224-float32"
3+
location = "us-central1"
4+
5+
model_config {
6+
accept_eula = true
7+
}
8+
9+
endpoint_config {
10+
private_service_connect_config {
11+
enable_private_service_connect = true
12+
project_allowlist = ["my-project-id"]
13+
}
14+
}
15+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
resource "google_vertex_ai_endpoint_with_model_garden_deployment" "{{$.PrimaryResourceId}}" {
2+
publisher_model_name = "publishers/google/models/paligemma@paligemma-224-float32"
3+
location = "us-central1"
4+
5+
model_config {
6+
accept_eula = true
7+
}
8+
9+
endpoint_config {
10+
private_service_connect_config {
11+
enable_private_service_connect = true
12+
project_allowlist = [data.google_project.project.id]
13+
14+
psc_automation_configs {
15+
project_id = data.google_project.project.id
16+
network = google_compute_network.network.id
17+
}
18+
}
19+
}
20+
}
21+
22+
resource "google_compute_subnetwork" "subnetwork" {
23+
name = "subnetwork"
24+
ip_cidr_range = "192.168.0.0/24"
25+
region = "us-central1"
26+
network = google_compute_network.network.id
27+
}
28+
29+
resource "google_compute_network" "network" {
30+
name = "network"
31+
auto_create_subnetworks = false
32+
}
33+
34+
data "google_project" "project" {}

mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_deploy_test.go

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,97 @@ resource "google_vertex_ai_endpoint_with_model_garden_deployment" "deploy-llama-
189189
`, context)
190190
}
191191

192+
func TestAccVertexAIEndpointWithModelGardenDeployment_pscEndpoint(t *testing.T) {
193+
t.Parallel()
194+
context := map[string]interface{}{"random_suffix": acctest.RandString(t, 10)}
195+
acctest.VcrTest(t, resource.TestCase{
196+
PreCheck: func() { acctest.AccTestPreCheck(t) },
197+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
198+
CheckDestroy: testAccCheckVertexAIEndpointWithModelGardenDeploymentDestroyProducer(t),
199+
Steps: []resource.TestStep{
200+
{
201+
Config: testAccVertexAIEndpointWithModelGardenDeployment_pscEndpoint(context),
202+
},
203+
},
204+
})
205+
}
206+
207+
func testAccVertexAIEndpointWithModelGardenDeployment_pscEndpoint(context map[string]interface{}) string {
208+
return acctest.Nprintf(`
209+
resource "google_vertex_ai_endpoint_with_model_garden_deployment" "test" {
210+
publisher_model_name = "publishers/google/models/paligemma@paligemma-224-float32"
211+
location = "us-central1"
212+
213+
model_config {
214+
accept_eula = true
215+
}
216+
217+
endpoint_config {
218+
private_service_connect_config {
219+
enable_private_service_connect = true
220+
project_allowlist = [data.google_project.project.id]
221+
}
222+
}
223+
}
224+
225+
data "google_project" "project" {}
226+
`, context)
227+
}
228+
229+
func TestAccVertexAIEndpointWithModelGardenDeployment_pscEndpointAutomated(t *testing.T) {
230+
t.Parallel()
231+
context := map[string]interface{}{"random_suffix": acctest.RandString(t, 10)}
232+
acctest.VcrTest(t, resource.TestCase{
233+
PreCheck: func() { acctest.AccTestPreCheck(t) },
234+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
235+
CheckDestroy: testAccCheckVertexAIEndpointWithModelGardenDeploymentDestroyProducer(t),
236+
Steps: []resource.TestStep{
237+
{
238+
Config: testAccVertexAIEndpointWithModelGardenDeployment_pscEndpointAutomated(context),
239+
},
240+
},
241+
})
242+
}
243+
244+
func testAccVertexAIEndpointWithModelGardenDeployment_pscEndpointAutomated(context map[string]interface{}) string {
245+
return acctest.Nprintf(`
246+
resource "google_vertex_ai_endpoint_with_model_garden_deployment" "test" {
247+
publisher_model_name = "publishers/google/models/paligemma@paligemma-224-float32"
248+
location = "us-central1"
249+
250+
model_config {
251+
accept_eula = true
252+
}
253+
254+
endpoint_config {
255+
private_service_connect_config {
256+
enable_private_service_connect = true
257+
project_allowlist = [data.google_project.project.id]
258+
259+
psc_automation_configs {
260+
project_id = data.google_project.project.id
261+
network = google_compute_network.network.id
262+
}
263+
}
264+
}
265+
}
266+
267+
resource "google_compute_subnetwork" "subnetwork" {
268+
name = "subnetwork"
269+
ip_cidr_range = "192.168.0.0/24"
270+
region = "us-central1"
271+
network = google_compute_network.network.id
272+
}
273+
274+
resource "google_compute_network" "network" {
275+
name = "network"
276+
auto_create_subnetworks = false
277+
}
278+
279+
data "google_project" "project" {}
280+
`, context)
281+
}
282+
192283
func testAccCheckVertexAIEndpointWithModelGardenDeploymentDestroyProducer(t *testing.T) func(s *terraform.State) error {
193284
return func(s *terraform.State) error {
194285
for name, rs := range s.RootModule().Resources {

0 commit comments

Comments
 (0)