Skip to content

Commit

Permalink
Adding missing fields to vertexai.Endpoint resource (#12110)
Browse files Browse the repository at this point in the history
[upstream:ee5b3de20ce91c5cf5cffd417512a498ff16e09f]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Nov 4, 2024
1 parent 8b5b1b7 commit bbf2ab4
Show file tree
Hide file tree
Showing 7 changed files with 1,010 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .changelog/12110.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
vertexai: added `traffic_split`, `private_service_connect_config`, `predict_request_response_logging_config`, `dedicated_endpoint_enabled`, and `dedicated_endpoint_dns` fields to `google_vertex_ai_endpoint` resource
```
301 changes: 301 additions & 0 deletions google-beta/services/vertexai/iam_vertex_ai_endpoint_generated_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package vertexai_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"

"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar"
)

func TestAccVertexAIEndpointIamBindingGenerated(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"role": "roles/viewer",
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccVertexAIEndpointIamBinding_basicGenerated(context),
},
{
ResourceName: "google_vertex_ai_endpoint_iam_binding.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/endpoints/%s roles/viewer", envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), fmt.Sprintf("endpoint-name%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
{
// Test Iam Binding update
Config: testAccVertexAIEndpointIamBinding_updateGenerated(context),
},
{
ResourceName: "google_vertex_ai_endpoint_iam_binding.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/endpoints/%s roles/viewer", envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), fmt.Sprintf("endpoint-name%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccVertexAIEndpointIamMemberGenerated(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"role": "roles/viewer",
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
// Test Iam Member creation (no update for member, no need to test)
Config: testAccVertexAIEndpointIamMember_basicGenerated(context),
},
{
ResourceName: "google_vertex_ai_endpoint_iam_member.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/endpoints/%s roles/viewer user:[email protected]", envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), fmt.Sprintf("endpoint-name%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccVertexAIEndpointIamPolicyGenerated(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"role": "roles/viewer",
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccVertexAIEndpointIamPolicy_basicGenerated(context),
Check: resource.TestCheckResourceAttrSet("data.google_vertex_ai_endpoint_iam_policy.foo", "policy_data"),
},
{
ResourceName: "google_vertex_ai_endpoint_iam_policy.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/endpoints/%s", envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), fmt.Sprintf("endpoint-name%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccVertexAIEndpointIamPolicy_emptyBinding(context),
},
{
ResourceName: "google_vertex_ai_endpoint_iam_policy.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/endpoints/%s", envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), fmt.Sprintf("endpoint-name%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccVertexAIEndpointIamMember_basicGenerated(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_vertex_ai_endpoint" "endpoint" {
name = "endpoint-name%{random_suffix}"
display_name = "sample-endpoint"
description = "A sample vertex endpoint"
location = "us-central1"
region = "us-central1"
labels = {
label-one = "value-one"
}
private_service_connect_config {
enable_private_service_connect = true
project_allowlist = [
"${data.google_project.project.project_id}"
]
enable_secure_private_service_connect = false
}
}
data "google_project" "project" {}
resource "google_vertex_ai_endpoint_iam_member" "foo" {
project = google_vertex_ai_endpoint.endpoint.project
location = google_vertex_ai_endpoint.endpoint.location
endpoint = google_vertex_ai_endpoint.endpoint.name
role = "%{role}"
member = "user:[email protected]"
}
`, context)
}

func testAccVertexAIEndpointIamPolicy_basicGenerated(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_vertex_ai_endpoint" "endpoint" {
name = "endpoint-name%{random_suffix}"
display_name = "sample-endpoint"
description = "A sample vertex endpoint"
location = "us-central1"
region = "us-central1"
labels = {
label-one = "value-one"
}
private_service_connect_config {
enable_private_service_connect = true
project_allowlist = [
"${data.google_project.project.project_id}"
]
enable_secure_private_service_connect = false
}
}
data "google_project" "project" {}
data "google_iam_policy" "foo" {
binding {
role = "%{role}"
members = ["user:[email protected]"]
}
}
resource "google_vertex_ai_endpoint_iam_policy" "foo" {
project = google_vertex_ai_endpoint.endpoint.project
location = google_vertex_ai_endpoint.endpoint.location
endpoint = google_vertex_ai_endpoint.endpoint.name
policy_data = data.google_iam_policy.foo.policy_data
}
data "google_vertex_ai_endpoint_iam_policy" "foo" {
project = google_vertex_ai_endpoint.endpoint.project
location = google_vertex_ai_endpoint.endpoint.location
endpoint = google_vertex_ai_endpoint.endpoint.name
depends_on = [
google_vertex_ai_endpoint_iam_policy.foo
]
}
`, context)
}

func testAccVertexAIEndpointIamPolicy_emptyBinding(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_vertex_ai_endpoint" "endpoint" {
name = "endpoint-name%{random_suffix}"
display_name = "sample-endpoint"
description = "A sample vertex endpoint"
location = "us-central1"
region = "us-central1"
labels = {
label-one = "value-one"
}
private_service_connect_config {
enable_private_service_connect = true
project_allowlist = [
"${data.google_project.project.project_id}"
]
enable_secure_private_service_connect = false
}
}
data "google_project" "project" {}
data "google_iam_policy" "foo" {
}
resource "google_vertex_ai_endpoint_iam_policy" "foo" {
project = google_vertex_ai_endpoint.endpoint.project
location = google_vertex_ai_endpoint.endpoint.location
endpoint = google_vertex_ai_endpoint.endpoint.name
policy_data = data.google_iam_policy.foo.policy_data
}
`, context)
}

func testAccVertexAIEndpointIamBinding_basicGenerated(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_vertex_ai_endpoint" "endpoint" {
name = "endpoint-name%{random_suffix}"
display_name = "sample-endpoint"
description = "A sample vertex endpoint"
location = "us-central1"
region = "us-central1"
labels = {
label-one = "value-one"
}
private_service_connect_config {
enable_private_service_connect = true
project_allowlist = [
"${data.google_project.project.project_id}"
]
enable_secure_private_service_connect = false
}
}
data "google_project" "project" {}
resource "google_vertex_ai_endpoint_iam_binding" "foo" {
project = google_vertex_ai_endpoint.endpoint.project
location = google_vertex_ai_endpoint.endpoint.location
endpoint = google_vertex_ai_endpoint.endpoint.name
role = "%{role}"
members = ["user:[email protected]"]
}
`, context)
}

func testAccVertexAIEndpointIamBinding_updateGenerated(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_vertex_ai_endpoint" "endpoint" {
name = "endpoint-name%{random_suffix}"
display_name = "sample-endpoint"
description = "A sample vertex endpoint"
location = "us-central1"
region = "us-central1"
labels = {
label-one = "value-one"
}
private_service_connect_config {
enable_private_service_connect = true
project_allowlist = [
"${data.google_project.project.project_id}"
]
enable_secure_private_service_connect = false
}
}
data "google_project" "project" {}
resource "google_vertex_ai_endpoint_iam_binding" "foo" {
project = google_vertex_ai_endpoint.endpoint.project
location = google_vertex_ai_endpoint.endpoint.location
endpoint = google_vertex_ai_endpoint.endpoint.name
role = "%{role}"
members = ["user:[email protected]", "user:[email protected]"]
}
`, context)
}
4 changes: 2 additions & 2 deletions google-beta/services/vertexai/iam_vertex_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestAccVertexAIEndpointIamPolicy(t *testing.T) {
ImportStateVerify: true,
},
{
Config: testAccVertexAIEndpointIamPolicy_emptyBinding(context),
Config: testAccVertexAIEndpointIamPolicy_emptyBindingManual(context),
},
{
ResourceName: "google_vertex_ai_endpoint_iam_policy.foo",
Expand Down Expand Up @@ -218,7 +218,7 @@ endpoint = google_vertex_ai_endpoint.endpoint.name
`, context)
}

func testAccVertexAIEndpointIamPolicy_emptyBinding(context map[string]interface{}) string {
func testAccVertexAIEndpointIamPolicy_emptyBindingManual(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_vertex_ai_endpoint" "endpoint" {
name = "tf-test-endpoint-name%{random_suffix}"
Expand Down
Loading

0 comments on commit bbf2ab4

Please sign in to comment.