diff --git a/.changelog/8852.txt b/.changelog/8852.txt new file mode 100644 index 00000000000..1ead1e015d3 --- /dev/null +++ b/.changelog/8852.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +vertexai: added `public_endpoint_enabled` to `google_vertex_ai_index_endpoint` +``` diff --git a/google/services/vertexai/resource_vertex_ai_index_endpoint.go b/google/services/vertexai/resource_vertex_ai_index_endpoint.go index 7dce17b2fa2..fcbeb7a10fd 100644 --- a/google/services/vertexai/resource_vertex_ai_index_endpoint.go +++ b/google/services/vertexai/resource_vertex_ai_index_endpoint.go @@ -73,6 +73,12 @@ Private services access must already be configured for the network. If left unsp [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.`, }, + "public_endpoint_enabled": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `If true, the deployed index will be accessible through public endpoint.`, + }, "region": { Type: schema.TypeString, Optional: true, @@ -94,6 +100,11 @@ Where '{project}' is a project number, as in '12345', and '{network}' is network Computed: true, Description: `The resource name of the Index.`, }, + "public_endpoint_domain_name": { + Type: schema.TypeString, + Computed: true, + Description: `If publicEndpointEnabled is true, this field will be populated with the domain name to use for this index endpoint.`, + }, "update_time": { Type: schema.TypeString, Computed: true, @@ -142,6 +153,12 @@ func resourceVertexAIIndexEndpointCreate(d *schema.ResourceData, meta interface{ } else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) { obj["network"] = networkProp } + publicEndpointEnabledProp, err := expandVertexAIIndexEndpointPublicEndpointEnabled(d.Get("public_endpoint_enabled"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("public_endpoint_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(publicEndpointEnabledProp)) && (ok || !reflect.DeepEqual(v, publicEndpointEnabledProp)) { + obj["publicEndpointEnabled"] = publicEndpointEnabledProp + } url, err := tpgresource.ReplaceVars(d, config, "{{VertexAIBasePath}}projects/{{project}}/locations/{{region}}/indexEndpoints") if err != nil { @@ -272,6 +289,9 @@ func resourceVertexAIIndexEndpointRead(d *schema.ResourceData, meta interface{}) if err := d.Set("network", flattenVertexAIIndexEndpointNetwork(res["network"], d, config)); err != nil { return fmt.Errorf("Error reading IndexEndpoint: %s", err) } + if err := d.Set("public_endpoint_domain_name", flattenVertexAIIndexEndpointPublicEndpointDomainName(res["publicEndpointDomainName"], d, config)); err != nil { + return fmt.Errorf("Error reading IndexEndpoint: %s", err) + } return nil } @@ -466,6 +486,10 @@ func flattenVertexAIIndexEndpointNetwork(v interface{}, d *schema.ResourceData, return v } +func flattenVertexAIIndexEndpointPublicEndpointDomainName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func expandVertexAIIndexEndpointDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -488,3 +512,7 @@ func expandVertexAIIndexEndpointLabels(v interface{}, d tpgresource.TerraformRes func expandVertexAIIndexEndpointNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } + +func expandVertexAIIndexEndpointPublicEndpointEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} diff --git a/google/services/vertexai/resource_vertex_ai_index_endpoint_generated_test.go b/google/services/vertexai/resource_vertex_ai_index_endpoint_generated_test.go index 8e1f0f35061..15b68dab431 100644 --- a/google/services/vertexai/resource_vertex_ai_index_endpoint_generated_test.go +++ b/google/services/vertexai/resource_vertex_ai_index_endpoint_generated_test.go @@ -50,7 +50,7 @@ func TestAccVertexAIIndexEndpoint_vertexAiIndexEndpointExample(t *testing.T) { ResourceName: "google_vertex_ai_index_endpoint.index_endpoint", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"etag", "region"}, + ImportStateVerifyIgnore: []string{"etag", "public_endpoint_enabled", "region"}, }, }, }) @@ -93,6 +93,47 @@ data "google_project" "project" {} `, context) } +func TestAccVertexAIIndexEndpoint_vertexAiIndexEndpointWithPublicEndpointExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "network_name": acctest.BootstrapSharedTestNetwork(t, "vertex-ai-index-endpoint"), + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckVertexAIIndexEndpointDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccVertexAIIndexEndpoint_vertexAiIndexEndpointWithPublicEndpointExample(context), + }, + { + ResourceName: "google_vertex_ai_index_endpoint.index_endpoint", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"etag", "public_endpoint_enabled", "region"}, + }, + }, + }) +} + +func testAccVertexAIIndexEndpoint_vertexAiIndexEndpointWithPublicEndpointExample(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_vertex_ai_index_endpoint" "index_endpoint" { + display_name = "sample-endpoint" + description = "A sample vertex endpoint with an public endpoint" + region = "us-central1" + labels = { + label-one = "value-one" + } + + public_endpoint_enabled = true +} +`, context) +} + func testAccCheckVertexAIIndexEndpointDestroyProducer(t *testing.T) func(s *terraform.State) error { return func(s *terraform.State) error { for name, rs := range s.RootModule().Resources { diff --git a/website/docs/r/vertex_ai_index_endpoint.html.markdown b/website/docs/r/vertex_ai_index_endpoint.html.markdown index d6b39f578d3..19cfb33ab7d 100644 --- a/website/docs/r/vertex_ai_index_endpoint.html.markdown +++ b/website/docs/r/vertex_ai_index_endpoint.html.markdown @@ -68,6 +68,26 @@ data "google_compute_network" "vertex_network" { data "google_project" "project" {} ``` +
+ + Open in Cloud Shell + +
+## Example Usage - Vertex Ai Index Endpoint With Public Endpoint + + +```hcl +resource "google_vertex_ai_index_endpoint" "index_endpoint" { + display_name = "sample-endpoint" + description = "A sample vertex endpoint with an public endpoint" + region = "us-central1" + labels = { + label-one = "value-one" + } + + public_endpoint_enabled = true +} +``` ## Argument Reference @@ -97,6 +117,10 @@ The following arguments are supported: [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. +* `public_endpoint_enabled` - + (Optional) + If true, the deployed index will be accessible through public endpoint. + * `region` - (Optional) The region of the index endpoint. eg us-central1 @@ -123,6 +147,9 @@ In addition to the arguments listed above, the following computed attributes are * `update_time` - The timestamp of when the Index was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. +* `public_endpoint_domain_name` - + If publicEndpointEnabled is true, this field will be populated with the domain name to use for this index endpoint. + ## Timeouts