Skip to content
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

Add Vertex ML Metadata Store #4951

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 82 additions & 1 deletion mmv1/products/vertexai/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,86 @@ objects:
Configuration of the snapshot analysis based monitoring pipeline running interval. The value is rolled up to full day.
A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".
# Vertex ML Metadata
- !ruby/object:Api::Resource
name: MetadataStore
base_url: projects/{{project}}/locations/{{region}}/metadataStores
self_link: 'projects/{{project}}/locations/{{region}}/metadataStores/{{name}}'
create_url: projects/{{project}}/locations/{{region}}/metadataStores?metadataStoreId={{name}}
min_version: beta
input: true
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
'https://cloud.google.com/vertex-ai/docs'
api: 'https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.metadataStores'
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
result: !ruby/object:Api::OpAsync::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
description: |-
Instance of a metadata store. Contains a set of metadata that can be queried.
parameters:
- !ruby/object:Api::Type::String
name: region
description: The region of the Metadata Store. eg us-central1
url_param_only: true
input: true
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: The name of the MetadataStore. This value may be up to 60 characters, and valid characters are [a-z0-9_]. The first character cannot be a number.
input: true
url_param_only: true
pattern: projects/{{project}}/locations/{{region}}/featurestores/{{name}}
- !ruby/object:Api::Type::String
name: 'description'
description: Description of the MetadataStore.
input: true
- !ruby/object:Api::Type::String
name: 'createTime'
output: true
description: |
The timestamp of when the MetadataStore was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
- !ruby/object:Api::Type::String
name: 'updateTime'
output: true
description: |
The timestamp of when the MetadataStore was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
- !ruby/object:Api::Type::NestedObject
name: 'encryptionSpec'
input: true
description: |
Customer-managed encryption key spec for a Dataset. If set, this MetadataStore and all sub-resources of this MetadataStore will be secured by this key.
properties:
- !ruby/object:Api::Type::String
name: 'kmsKeyName'
description: |
Required. The Cloud KMS resource identifier of the customer managed encryption key used to protect a resource.
Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the resource is created.
input: true
- !ruby/object:Api::Type::NestedObject
name: 'state'
output: true
description: |
State information of the MetadataStore.
properties:
- !ruby/object:Api::Type::String
name: 'diskUtilizationBytes'
description: |
The disk utilization of the MetadataStore in bytes.
output: true

20 changes: 20 additions & 0 deletions mmv1/products/vertexai/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ overrides: !ruby/object:Overrides::ResourceOverrides
pre_create: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb
pre_update: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb
pre_delete: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb
MetadataStore: !ruby/object:Overrides::Terraform::ResourceOverride
autogen_async: false
id_format: '{{name}}'
skip_sweeper: true
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 15 # Inserts with KMS take 10+ minutes
delete_minutes: 15
examples:
- !ruby/object:Provider::Terraform::Examples
name: "vertex_ai_metadata_store"
skip_test: true
primary_resource_id: "store"
vars:
name: "tf-test-"
properties:
name: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb
region: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true

# This is for copying files over
files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
Expand Down
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"
}
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 -%>