Skip to content

Commit 42a7547

Browse files
feat(vertexai): Make it possible to use Private Service Connect in Vertex AI Index Endpoint (#8851) (#1673)
[upstream:20ab4e9c5fefe34ee1514a19825501b4f806733a] Signed-off-by: Modular Magician <[email protected]>
1 parent 8b15591 commit 42a7547

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/hashicorp/hcl/v2 v2.19.1
1212
github.com/hashicorp/terraform-json v0.17.1
1313
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
14-
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231107201940-55dc09087e14
14+
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231107235957-55a95b6345ad
1515
github.com/mitchellh/go-homedir v1.1.0 // indirect
1616
github.com/pkg/errors v0.9.1
1717
github.com/stretchr/testify v1.8.3

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwU
169169
github.com/hashicorp/terraform-plugin-mux v0.8.0 h1:WCTP66mZ+iIaIrCNJnjPEYnVjawTshnDJu12BcXK1EI=
170170
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 h1:wcOKYwPI9IorAJEBLzgclh3xVolO7ZorYd6U1vnok14=
171171
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0/go.mod h1:qH/34G25Ugdj5FcM95cSoXzUgIbgfhVLXCcEcYaMwq8=
172-
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231107201940-55dc09087e14 h1:WzNvAaUIOr8vqy+asiiTNkamhXDN4UoZmusuYeRgt3k=
173-
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231107201940-55dc09087e14/go.mod h1:hOUMXZXm7ztJQn7kTMlHgG3jh7ZoLMriRFbV2t7sA8o=
172+
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231107235957-55a95b6345ad h1:gedti28/mUdNkCA9RY6HFiLn+O0+cOZXbyLsE0NMmVw=
173+
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231107235957-55a95b6345ad/go.mod h1:hOUMXZXm7ztJQn7kTMlHgG3jh7ZoLMriRFbV2t7sA8o=
174174
github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno=
175175
github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo=
176176
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=

tfplan2cai/converters/google/resources/services/vertexai/vertexai_index_endpoint.go

+40
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ func GetVertexAIIndexEndpointApiObject(d tpgresource.TerraformResourceData, conf
7272
} else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) {
7373
obj["network"] = networkProp
7474
}
75+
privateServiceConnectConfigProp, err := expandVertexAIIndexEndpointPrivateServiceConnectConfig(d.Get("private_service_connect_config"), d, config)
76+
if err != nil {
77+
return nil, err
78+
} else if v, ok := d.GetOkExists("private_service_connect_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(privateServiceConnectConfigProp)) && (ok || !reflect.DeepEqual(v, privateServiceConnectConfigProp)) {
79+
obj["privateServiceConnectConfig"] = privateServiceConnectConfigProp
80+
}
7581
publicEndpointEnabledProp, err := expandVertexAIIndexEndpointPublicEndpointEnabled(d.Get("public_endpoint_enabled"), d, config)
7682
if err != nil {
7783
return nil, err
@@ -100,6 +106,40 @@ func expandVertexAIIndexEndpointNetwork(v interface{}, d tpgresource.TerraformRe
100106
return v, nil
101107
}
102108

109+
func expandVertexAIIndexEndpointPrivateServiceConnectConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
110+
l := v.([]interface{})
111+
if len(l) == 0 || l[0] == nil {
112+
return nil, nil
113+
}
114+
raw := l[0]
115+
original := raw.(map[string]interface{})
116+
transformed := make(map[string]interface{})
117+
118+
transformedEnablePrivateServiceConnect, err := expandVertexAIIndexEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(original["enable_private_service_connect"], d, config)
119+
if err != nil {
120+
return nil, err
121+
} else if val := reflect.ValueOf(transformedEnablePrivateServiceConnect); val.IsValid() && !tpgresource.IsEmptyValue(val) {
122+
transformed["enablePrivateServiceConnect"] = transformedEnablePrivateServiceConnect
123+
}
124+
125+
transformedProjectAllowlist, err := expandVertexAIIndexEndpointPrivateServiceConnectConfigProjectAllowlist(original["project_allowlist"], d, config)
126+
if err != nil {
127+
return nil, err
128+
} else if val := reflect.ValueOf(transformedProjectAllowlist); val.IsValid() && !tpgresource.IsEmptyValue(val) {
129+
transformed["projectAllowlist"] = transformedProjectAllowlist
130+
}
131+
132+
return transformed, nil
133+
}
134+
135+
func expandVertexAIIndexEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
136+
return v, nil
137+
}
138+
139+
func expandVertexAIIndexEndpointPrivateServiceConnectConfigProjectAllowlist(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
140+
return v, nil
141+
}
142+
103143
func expandVertexAIIndexEndpointPublicEndpointEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
104144
return v, nil
105145
}

0 commit comments

Comments
 (0)