forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Vertex ML Metadata Store (GoogleCloudPlatform#4951)
Co-authored-by: upodroid <cy@borg.dev> Co-authored-by: Cameron Thornton <camthornton@google.com>
- Loading branch information
1 parent
826dd58
commit fdb3c12
Showing
4 changed files
with
192 additions
and
1 deletion.
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
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
5 changes: 5 additions & 0 deletions
5
mmv1/templates/terraform/examples/vertex_ai_metadata_store.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,5 @@ | ||
resource "google_vertex_ai_metadata_store" "dataset" { | ||
name = "<%= ctx[:vars]['name'] %>" | ||
description = "magic" | ||
region = "us-central1" | ||
} |
85 changes: 85 additions & 0 deletions
85
mmv1/third_party/terraform/tests/resource_vertex_ai_metadata_store_test.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,85 @@ | ||
<% autogen_exception -%> | ||
package google | ||
<% unless version == 'ga' -%> | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"strings" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
) | ||
|
||
func TestAccVertexAIMetadataStore_vertexAiMetadataStoreExample(t *testing.T) { | ||
t.Parallel() | ||
|
||
kms := BootstrapKMSKeyInLocation(t, "us-central1") | ||
name := fmt.Sprintf("tf-test-%s", randString(t, 10)) | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckVertexAIMetadataStoreDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccVertexAIMetadataStore_vertexAiMetadataStoreExample(name, kms.CryptoKey.Name), | ||
}, | ||
{ | ||
ResourceName: "google_vertex_ai_metadata_store.store", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"region"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccVertexAIMetadataStore_vertexAiMetadataStoreExample(name, kmsKey string) string { | ||
return fmt.Sprintf(` | ||
resource "google_vertex_ai_metadata_store" "store" { | ||
name = "%s" | ||
description = "Magic" | ||
region = "us-central1" | ||
encryption_spec { | ||
kms_key_name = "%s" | ||
} | ||
} | ||
`, name, kmsKey) | ||
} | ||
|
||
func testAccCheckVertexAIMetadataStoreDestroyProducer(t *testing.T) func(s *terraform.State) error { | ||
return func(s *terraform.State) error { | ||
for name, rs := range s.RootModule().Resources { | ||
if rs.Type != "google_vertex_ai_metadata_store" { | ||
continue | ||
} | ||
if strings.HasPrefix(name, "data.") { | ||
continue | ||
} | ||
|
||
config := googleProviderConfig(t) | ||
|
||
url, err := replaceVarsForTest(config, rs, "{{VertexAIBasePath}}{{name}}") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
billingProject := "" | ||
|
||
if config.BillingProject != "" { | ||
billingProject = config.BillingProject | ||
} | ||
|
||
_, err = sendRequest(config, "GET", billingProject, url, config.userAgent, nil) | ||
if err == nil { | ||
return fmt.Errorf("VertexAIMetadataStore still exists at %s", url) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
|
||
<% end -%> |