diff --git a/mmv1/templates/terraform/custom_flatten/vertex_ai_name_from_model.go.erb b/mmv1/templates/terraform/custom_flatten/vertex_ai_name_from_model.go.erb new file mode 100644 index 000000000000..d6dcef6856ec --- /dev/null +++ b/mmv1/templates/terraform/custom_flatten/vertex_ai_name_from_model.go.erb @@ -0,0 +1,7 @@ +func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if d.Get("name").(string) == "" { + return v.(string) + } + + return d.Get("name") +} \ No newline at end of file diff --git a/mmv1/templates/terraform/decoders/vertex_ai_models.go.erb b/mmv1/templates/terraform/decoders/vertex_ai_models.go.erb new file mode 100644 index 000000000000..66985ff32565 --- /dev/null +++ b/mmv1/templates/terraform/decoders/vertex_ai_models.go.erb @@ -0,0 +1,4 @@ +if res["model"] != "" { + res["name"] = res["model"] +} +return res, nil \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/vertex_ai_model_basic.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_model_basic.tf.erb new file mode 100644 index 000000000000..4bbb7740aabc --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_model_basic.tf.erb @@ -0,0 +1,13 @@ +resource "google_vertex_ai_models" "<%= ctx[:primary_resource_id] %>" { + display_name = "<%= ctx[:vars]['display_name'] %>" + description = "sample description" + labels = { + "key1" : "value1", + "key2" : "value2" + } + region = "us-central1" + encryption_spec { + kms_key_name = "<%= ctx[:vars]['kms_key_name'] %>" + } + depends_on = [google_kms_crypto_key_iam_member.crypto_key] +} \ No newline at end of file diff --git a/mmv1/templates/terraform/pre_create/vertex_ai_models.go.erb b/mmv1/templates/terraform/pre_create/vertex_ai_models.go.erb new file mode 100644 index 000000000000..d0dea95f6ce5 --- /dev/null +++ b/mmv1/templates/terraform/pre_create/vertex_ai_models.go.erb @@ -0,0 +1,9 @@ +var postRequestType string +if _, ok := d.GetOk("model"); ok { + postRequestType = ":upload" +} + +if _, ok := d.GetOk("source_model"); ok { + postRequestType = ":copy" +} +url = regexp.MustCompile("PRE_CREATE_REPLACE_ME").ReplaceAllLiteralString(url, postRequestType) \ No newline at end of file