-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(vertexai): Make it possible to use Private Service Connect in Vertex AI Index Endpoint #8851
Merged
shuyama1
merged 14 commits into
GoogleCloudPlatform:main
from
shotarok:support-psc-in-vertex-ai-index-endpoint
Nov 7, 2023
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
04dc267
feat: make it possible to use private service connect in vertex ai in…
shotarok a00f213
fix: revert changes regarding deployedIndexes
shotarok 1a0f1ea
refactor: removed unnecessary test_vars_overrides
shotarok debd2d1
feat: update the field's immutability and requirement
shotarok 4970888
feat: define conflicted fields
shotarok 6269755
Merge branch 'main' into support-psc-in-vertex-ai-index-endpoint
shotarok 40903e2
refactor: restore a deleted comment
shotarok 4db21fb
feat: add an example using 'enable_private_service_connect = false'
shotarok d57bdc8
feat: add an example using 'enable_private_service_connect = false' (…
shotarok 600459b
refactor: add skip_docs: true
shotarok f3aecd4
feat: add default_from_api: true
shotarok 576d771
feat: update the custom fllatter to deal with only when object is empty
shotarok 74c92d6
refactor: update the test example to be valid
shotarok 8d0230b
fix: move 'skip_docs: true' to the expected example
shotarok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,15 @@ examples: | |
network_name: "network-name" | ||
test_vars_overrides: | ||
network_name: 'acctest.BootstrapSharedTestNetwork(t, "vertex-ai-index-endpoint")' | ||
- !ruby/object:Provider::Terraform::Examples | ||
name: "vertex_ai_index_endpoint_with_psc" | ||
primary_resource_id: "index_endpoint" | ||
- !ruby/object:Provider::Terraform::Examples | ||
name: "vertex_ai_index_endpoint_with_false_psc" | ||
primary_resource_id: "index_endpoint" | ||
# It's not distinguishable if the psc is false or not set, so we need to skip the test. | ||
skip_import_test: true | ||
skip_docs: true | ||
- !ruby/object:Provider::Terraform::Examples | ||
name: "vertex_ai_index_endpoint_with_public_endpoint" | ||
primary_resource_id: "index_endpoint" | ||
|
@@ -102,6 +111,28 @@ properties: | |
[Format](https://cloud.google.com/compute/docs/reference/rest/v1/networks/insert): `projects/{project}/global/networks/{network}`. | ||
Where `{project}` is a project number, as in `12345`, and `{network}` is network name. | ||
immutable: true | ||
conflicts: | ||
- privateServiceConnectConfig | ||
- !ruby/object:Api::Type::NestedObject | ||
name: privateServiceConnectConfig | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll likely need to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added it in f3aecd4. |
||
immutable: true | ||
default_from_api: true | ||
description: |- | ||
Optional. Configuration for private service connect. `network` and `privateServiceConnectConfig` are mutually exclusive. | ||
shotarok marked this conversation as resolved.
Show resolved
Hide resolved
|
||
conflicts: | ||
- network | ||
custom_flatten: templates/terraform/custom_flatten/vertex_ai_index_endpoint_private_service_connect_config.go.erb | ||
properties: | ||
- !ruby/object:Api::Type::Boolean | ||
name: enablePrivateServiceConnect | ||
description: If set to true, the IndexEndpoint is created without private service access. | ||
immutable: true | ||
required: true | ||
- !ruby/object:Api::Type::Array | ||
name: projectAllowlist | ||
description: A list of Projects from which the forwarding rule will target the service attachment. | ||
item_type: Api::Type::String | ||
immutable: true | ||
- !ruby/object:Api::Type::Boolean | ||
name: publicEndpointEnabled | ||
immutable: true | ||
|
42 changes: 42 additions & 0 deletions
42
...s/terraform/custom_flatten/vertex_ai_index_endpoint_private_service_connect_config.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
transformed := make(map[string]interface{}) | ||
|
||
if v == nil { | ||
// Disabled by default, but API will not return object if value is false | ||
transformed["enable_private_service_connect"] = false | ||
return []interface{}{transformed} | ||
} | ||
|
||
original := v.(map[string]interface{}) | ||
if len(original) == 0 { | ||
return nil | ||
} | ||
|
||
transformed["enable_private_service_connect"] = | ||
flattenVertexAIIndexEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(original["enablePrivateServiceConnect"], d, config) | ||
transformed["project_allowlist"] = | ||
flattenVertexAIIndexEndpointPrivateServiceConnectConfigProjectAllowlist(original["projectAllowlist"], d, config) | ||
return []interface{}{transformed} | ||
} | ||
|
||
func flattenVertexAIIndexEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
return v | ||
} | ||
|
||
func flattenVertexAIIndexEndpointPrivateServiceConnectConfigProjectAllowlist(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
return v | ||
} |
12 changes: 12 additions & 0 deletions
12
mmv1/templates/terraform/examples/vertex_ai_index_endpoint_with_false_psc.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "google_vertex_ai_index_endpoint" "<%= ctx[:primary_resource_id] %>" { | ||
display_name = "sample-endpoint" | ||
description = "A sample vertex endpoint" | ||
region = "us-central1" | ||
labels = { | ||
label-one = "value-one" | ||
} | ||
|
||
private_service_connect_config { | ||
enable_private_service_connect = false | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
mmv1/templates/terraform/examples/vertex_ai_index_endpoint_with_psc.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
resource "google_vertex_ai_index_endpoint" "<%= ctx[:primary_resource_id] %>" { | ||
display_name = "sample-endpoint" | ||
description = "A sample vertex endpoint" | ||
region = "us-central1" | ||
labels = { | ||
label-one = "value-one" | ||
} | ||
|
||
private_service_connect_config { | ||
enable_private_service_connect = true | ||
project_allowlist = [ | ||
data.google_project.project.number, | ||
] | ||
} | ||
} | ||
|
||
data "google_project" "project" {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can add
skip_doc
to skip the documentation generation for this exampleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it in 600459b.