Skip to content

Commit 1196736

Browse files
vertexai: add psc_automation_configs argument to google_vertex_ai_endpoint (#15515) (#24870)
[upstream:fb4f6bc1b6227eb1221188015c1c148ef4016ef9] Signed-off-by: Modular Magician <[email protected]>
1 parent 197ef73 commit 1196736

File tree

5 files changed

+238
-0
lines changed

5 files changed

+238
-0
lines changed

.changelog/15515.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
vertexai: added `psc_automation_configs` field to `google_vertex_ai_endpoint` resource
3+
```

google/services/vertexai/resource_vertex_ai_endpoint.go

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,45 @@ Please refer to the field 'effective_labels' for all of the labels present on th
177177
Type: schema.TypeString,
178178
},
179179
},
180+
"psc_automation_configs": {
181+
Type: schema.TypeList,
182+
Optional: true,
183+
Description: `List of projects and networks where the PSC endpoints will be created. This field is used by Online Inference(Prediction) only.`,
184+
Elem: &schema.Resource{
185+
Schema: map[string]*schema.Schema{
186+
"network": {
187+
Type: schema.TypeString,
188+
Required: true,
189+
Description: `The full name of the Google Compute Engine [network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks). [Format](https://cloud.google.com/compute/docs/reference/rest/v1/networks/get): projects/{project}/global/networks/{network}.`,
190+
},
191+
"project_id": {
192+
Type: schema.TypeString,
193+
Required: true,
194+
Description: `Project id used to create forwarding rule.`,
195+
},
196+
"error_message": {
197+
Type: schema.TypeString,
198+
Computed: true,
199+
Description: `Error message if the PSC service automation failed.`,
200+
},
201+
"forwarding_rule": {
202+
Type: schema.TypeString,
203+
Computed: true,
204+
Description: `Forwarding rule created by the PSC service automation.`,
205+
},
206+
"ip_address": {
207+
Type: schema.TypeString,
208+
Computed: true,
209+
Description: `IP address rule created by the PSC service automation.`,
210+
},
211+
"state": {
212+
Type: schema.TypeString,
213+
Computed: true,
214+
Description: `The state of the PSC service automation.`,
215+
},
216+
},
217+
},
218+
},
180219
},
181220
},
182221
ConflictsWith: []string{"network", "dedicated_endpoint_enabled"},
@@ -1195,6 +1234,8 @@ func flattenVertexAIEndpointPrivateServiceConnectConfig(v interface{}, d *schema
11951234
flattenVertexAIEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(original["enablePrivateServiceConnect"], d, config)
11961235
transformed["project_allowlist"] =
11971236
flattenVertexAIEndpointPrivateServiceConnectConfigProjectAllowlist(original["projectAllowlist"], d, config)
1237+
transformed["psc_automation_configs"] =
1238+
flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigs(original["pscAutomationConfigs"], d, config)
11981239
return []interface{}{transformed}
11991240
}
12001241
func flattenVertexAIEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -1205,6 +1246,53 @@ func flattenVertexAIEndpointPrivateServiceConnectConfigProjectAllowlist(v interf
12051246
return v
12061247
}
12071248

1249+
func flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigs(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1250+
if v == nil {
1251+
return v
1252+
}
1253+
l := v.([]interface{})
1254+
transformed := make([]interface{}, 0, len(l))
1255+
for _, raw := range l {
1256+
original := raw.(map[string]interface{})
1257+
if len(original) < 1 {
1258+
// Do not include empty json objects coming back from the api
1259+
continue
1260+
}
1261+
transformed = append(transformed, map[string]interface{}{
1262+
"project_id": flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsProjectId(original["projectId"], d, config),
1263+
"network": flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsNetwork(original["network"], d, config),
1264+
"ip_address": flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsIpAddress(original["ipAddress"], d, config),
1265+
"forwarding_rule": flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsForwardingRule(original["forwardingRule"], d, config),
1266+
"state": flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsState(original["state"], d, config),
1267+
"error_message": flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsErrorMessage(original["errorMessage"], d, config),
1268+
})
1269+
}
1270+
return transformed
1271+
}
1272+
func flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsProjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1273+
return v
1274+
}
1275+
1276+
func flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1277+
return v
1278+
}
1279+
1280+
func flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsIpAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1281+
return v
1282+
}
1283+
1284+
func flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsForwardingRule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1285+
return v
1286+
}
1287+
1288+
func flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1289+
return v
1290+
}
1291+
1292+
func flattenVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsErrorMessage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1293+
return v
1294+
}
1295+
12081296
func flattenVertexAIEndpointModelDeploymentMonitoringJob(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
12091297
return v
12101298
}
@@ -1354,6 +1442,13 @@ func expandVertexAIEndpointPrivateServiceConnectConfig(v interface{}, d tpgresou
13541442
transformed["projectAllowlist"] = transformedProjectAllowlist
13551443
}
13561444

1445+
transformedPscAutomationConfigs, err := expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigs(original["psc_automation_configs"], d, config)
1446+
if err != nil {
1447+
return nil, err
1448+
} else if val := reflect.ValueOf(transformedPscAutomationConfigs); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1449+
transformed["pscAutomationConfigs"] = transformedPscAutomationConfigs
1450+
}
1451+
13571452
return transformed, nil
13581453
}
13591454

@@ -1365,6 +1460,90 @@ func expandVertexAIEndpointPrivateServiceConnectConfigProjectAllowlist(v interfa
13651460
return v, nil
13661461
}
13671462

1463+
func expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1464+
if v == nil {
1465+
return nil, nil
1466+
}
1467+
l := v.([]interface{})
1468+
req := make([]interface{}, 0, len(l))
1469+
for _, raw := range l {
1470+
if raw == nil {
1471+
continue
1472+
}
1473+
original := raw.(map[string]interface{})
1474+
transformed := make(map[string]interface{})
1475+
1476+
transformedProjectId, err := expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsProjectId(original["project_id"], d, config)
1477+
if err != nil {
1478+
return nil, err
1479+
} else if val := reflect.ValueOf(transformedProjectId); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1480+
transformed["projectId"] = transformedProjectId
1481+
}
1482+
1483+
transformedNetwork, err := expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsNetwork(original["network"], d, config)
1484+
if err != nil {
1485+
return nil, err
1486+
} else if val := reflect.ValueOf(transformedNetwork); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1487+
transformed["network"] = transformedNetwork
1488+
}
1489+
1490+
transformedIpAddress, err := expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsIpAddress(original["ip_address"], d, config)
1491+
if err != nil {
1492+
return nil, err
1493+
} else if val := reflect.ValueOf(transformedIpAddress); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1494+
transformed["ipAddress"] = transformedIpAddress
1495+
}
1496+
1497+
transformedForwardingRule, err := expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsForwardingRule(original["forwarding_rule"], d, config)
1498+
if err != nil {
1499+
return nil, err
1500+
} else if val := reflect.ValueOf(transformedForwardingRule); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1501+
transformed["forwardingRule"] = transformedForwardingRule
1502+
}
1503+
1504+
transformedState, err := expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsState(original["state"], d, config)
1505+
if err != nil {
1506+
return nil, err
1507+
} else if val := reflect.ValueOf(transformedState); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1508+
transformed["state"] = transformedState
1509+
}
1510+
1511+
transformedErrorMessage, err := expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsErrorMessage(original["error_message"], d, config)
1512+
if err != nil {
1513+
return nil, err
1514+
} else if val := reflect.ValueOf(transformedErrorMessage); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1515+
transformed["errorMessage"] = transformedErrorMessage
1516+
}
1517+
1518+
req = append(req, transformed)
1519+
}
1520+
return req, nil
1521+
}
1522+
1523+
func expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1524+
return v, nil
1525+
}
1526+
1527+
func expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1528+
return v, nil
1529+
}
1530+
1531+
func expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsIpAddress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1532+
return v, nil
1533+
}
1534+
1535+
func expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsForwardingRule(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1536+
return v, nil
1537+
}
1538+
1539+
func expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsState(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1540+
return v, nil
1541+
}
1542+
1543+
func expandVertexAIEndpointPrivateServiceConnectConfigPscAutomationConfigsErrorMessage(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1544+
return v, nil
1545+
}
1546+
13681547
func expandVertexAIEndpointPredictRequestResponseLoggingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
13691548
if v == nil {
13701549
return nil, nil

google/services/vertexai/resource_vertex_ai_endpoint_generated_meta.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ fields:
5050
- api_field: 'predictRequestResponseLoggingConfig.samplingRate'
5151
- api_field: 'privateServiceConnectConfig.enablePrivateServiceConnect'
5252
- api_field: 'privateServiceConnectConfig.projectAllowlist'
53+
- api_field: 'privateServiceConnectConfig.pscAutomationConfigs.errorMessage'
54+
- api_field: 'privateServiceConnectConfig.pscAutomationConfigs.forwardingRule'
55+
- api_field: 'privateServiceConnectConfig.pscAutomationConfigs.ipAddress'
56+
- api_field: 'privateServiceConnectConfig.pscAutomationConfigs.network'
57+
- api_field: 'privateServiceConnectConfig.pscAutomationConfigs.projectId'
58+
- api_field: 'privateServiceConnectConfig.pscAutomationConfigs.state'
5359
- field: 'region'
5460
provider_only: true
5561
- field: 'terraform_labels'

google/services/vertexai/resource_vertex_ai_endpoint_generated_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func TestAccVertexAIEndpoint_vertexAiEndpointPrivateServiceConnectExample(t *tes
5757

5858
func testAccVertexAIEndpoint_vertexAiEndpointPrivateServiceConnectExample(context map[string]interface{}) string {
5959
return acctest.Nprintf(`
60+
resource "google_compute_network" "default" {
61+
name = "tf-test-psc-network%{random_suffix}-%{random_suffix}"
62+
}
63+
6064
resource "google_vertex_ai_endpoint" "endpoint" {
6165
name = "endpoint-name%{random_suffix}"
6266
display_name = "sample-endpoint"
@@ -71,6 +75,11 @@ resource "google_vertex_ai_endpoint" "endpoint" {
7175
project_allowlist = [
7276
"${data.google_project.project.project_id}"
7377
]
78+
79+
psc_automation_configs {
80+
project_id = data.google_project.project.project_id
81+
network = google_compute_network.default.id
82+
}
7483
}
7584
}
7685

website/docs/r/vertex_ai_endpoint.html.markdown

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ data "google_project" "project" {}
106106

107107

108108
```hcl
109+
resource "google_compute_network" "default" {
110+
name = "psc-network-%{random_suffix}"
111+
}
112+
109113
resource "google_vertex_ai_endpoint" "endpoint" {
110114
name = "endpoint-name%{random_suffix}"
111115
display_name = "sample-endpoint"
@@ -120,6 +124,11 @@ resource "google_vertex_ai_endpoint" "endpoint" {
120124
project_allowlist = [
121125
"${data.google_project.project.project_id}"
122126
]
127+
128+
psc_automation_configs {
129+
project_id = data.google_project.project.project_id
130+
network = google_compute_network.default.id
131+
}
123132
}
124133
}
125134
@@ -238,6 +247,38 @@ The following arguments are supported:
238247
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
239248
If set to true, enable secure private service connect with IAM authorization. Otherwise, private service connect will be done without authorization. Note latency will be slightly increased if authorization is enabled.
240249

250+
* `psc_automation_configs` -
251+
(Optional)
252+
List of projects and networks where the PSC endpoints will be created. This field is used by Online Inference(Prediction) only.
253+
Structure is [documented below](#nested_private_service_connect_config_psc_automation_configs).
254+
255+
256+
<a name="nested_private_service_connect_config_psc_automation_configs"></a>The `psc_automation_configs` block supports:
257+
258+
* `project_id` -
259+
(Required)
260+
Project id used to create forwarding rule.
261+
262+
* `network` -
263+
(Required)
264+
The full name of the Google Compute Engine [network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks). [Format](https://cloud.google.com/compute/docs/reference/rest/v1/networks/get): projects/{project}/global/networks/{network}.
265+
266+
* `ip_address` -
267+
(Output)
268+
IP address rule created by the PSC service automation.
269+
270+
* `forwarding_rule` -
271+
(Output)
272+
Forwarding rule created by the PSC service automation.
273+
274+
* `state` -
275+
(Output)
276+
The state of the PSC service automation.
277+
278+
* `error_message` -
279+
(Output)
280+
Error message if the PSC service automation failed.
281+
241282
<a name="nested_predict_request_response_logging_config"></a>The `predict_request_response_logging_config` block supports:
242283

243284
* `enabled` -

0 commit comments

Comments
 (0)