-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add project_number field to featureview (#10857)
- Loading branch information
Showing
3 changed files
with
174 additions
and
0 deletions.
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
17 changes: 17 additions & 0 deletions
17
mmv1/templates/terraform/custom_flatten/vertex_ai_feature_view_ignore_project_number.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,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
return d.Get("feature_registry_source.0.project_number") | ||
} |
141 changes: 141 additions & 0 deletions
141
...emplates/terraform/examples/vertex_ai_featureonlinestore_featureview_cross_project.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,141 @@ | ||
data "google_project" "test_project" { | ||
} | ||
|
||
resource "google_project" "project" { | ||
project_id = "tf-test%{random_suffix}" | ||
name = "tf-test%{random_suffix}" | ||
org_id = "<%= ctx[:test_env_vars]['org_id'] %>" | ||
billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>" | ||
} | ||
|
||
resource "time_sleep" "wait_60_seconds" { | ||
depends_on = [google_project.project] | ||
|
||
create_duration = "60s" | ||
} | ||
|
||
resource "time_sleep" "wait_30_seconds" { | ||
depends_on = [google_bigquery_dataset_iam_member.viewer] | ||
|
||
create_duration = "30s" | ||
} | ||
|
||
resource "google_project_service" "vertexai" { | ||
service = "aiplatform.googleapis.com" | ||
project = google_project.project.project_id | ||
timeouts { | ||
create = "30m" | ||
update = "40m" | ||
} | ||
disable_on_destroy = false | ||
# Needed for CI tests for permissions to propagate, should not be needed for actual usage | ||
depends_on = [time_sleep.wait_60_seconds] | ||
} | ||
|
||
resource "google_bigquery_dataset_iam_member" "viewer" { | ||
project = data.google_project.test_project.project_id | ||
dataset_id = google_bigquery_dataset.sample_dataset.dataset_id | ||
role = "roles/bigquery.dataViewer" | ||
member = "serviceAccount:service-${google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com" | ||
depends_on = [google_vertex_ai_feature_online_store.featureonlinestore] | ||
} | ||
|
||
resource "google_vertex_ai_feature_online_store" "featureonlinestore" { | ||
name = "<%= ctx[:vars]['name'] %>" | ||
project = google_project.project.project_id | ||
labels = { | ||
foo = "bar" | ||
} | ||
region = "us-central1" | ||
bigtable { | ||
auto_scaling { | ||
min_node_count = 1 | ||
max_node_count = 2 | ||
cpu_utilization_target = 80 | ||
} | ||
} | ||
depends_on = [google_project_service.vertexai] | ||
} | ||
|
||
resource "google_bigquery_dataset" "sample_dataset" { | ||
dataset_id = "<%= ctx[:vars]['name'] %>" | ||
friendly_name = "test" | ||
description = "This is a test description" | ||
location = "US" | ||
} | ||
|
||
resource "google_bigquery_table" "sample_table" { | ||
deletion_protection = false | ||
dataset_id = google_bigquery_dataset.sample_dataset.dataset_id | ||
table_id = "<%= ctx[:vars]['name'] %>" | ||
|
||
schema = <<EOF | ||
[ | ||
{ | ||
"name": "feature_id", | ||
"type": "STRING", | ||
"mode": "NULLABLE" | ||
}, | ||
{ | ||
"name": "<%= ctx[:vars]['name'] %>", | ||
"type": "STRING", | ||
"mode": "NULLABLE" | ||
}, | ||
{ | ||
"name": "feature_timestamp", | ||
"type": "TIMESTAMP", | ||
"mode": "NULLABLE" | ||
} | ||
] | ||
EOF | ||
} | ||
|
||
resource "google_vertex_ai_feature_group" "sample_feature_group" { | ||
name = "<%= ctx[:vars]['name'] %>" | ||
description = "A sample feature group" | ||
region = "us-central1" | ||
labels = { | ||
label-one = "value-one" | ||
} | ||
big_query { | ||
big_query_source { | ||
# The source table must have a column named 'feature_timestamp' of type TIMESTAMP. | ||
input_uri = "bq://${google_bigquery_table.sample_table.project}.${google_bigquery_table.sample_table.dataset_id}.${google_bigquery_table.sample_table.table_id}" | ||
} | ||
entity_id_columns = ["feature_id"] | ||
} | ||
} | ||
|
||
|
||
|
||
resource "google_vertex_ai_feature_group_feature" "sample_feature" { | ||
name = "<%= ctx[:vars]['name'] %>" | ||
region = "us-central1" | ||
feature_group = google_vertex_ai_feature_group.sample_feature_group.name | ||
description = "A sample feature" | ||
labels = { | ||
label-one = "value-one" | ||
} | ||
} | ||
|
||
|
||
resource "google_vertex_ai_feature_online_store_featureview" "<%= ctx[:primary_resource_id] %>" { | ||
name = "<%= ctx[:vars]['name'] %>" | ||
project = google_project.project.project_id | ||
region = "us-central1" | ||
feature_online_store = google_vertex_ai_feature_online_store.featureonlinestore.name | ||
sync_config { | ||
cron = "0 0 * * *" | ||
} | ||
feature_registry_source { | ||
|
||
feature_groups { | ||
feature_group_id = google_vertex_ai_feature_group.sample_feature_group.name | ||
feature_ids = [google_vertex_ai_feature_group_feature.sample_feature.name] | ||
} | ||
project_number = data.google_project.test_project.number | ||
|
||
} | ||
depends_on = [google_project_service.vertexai, time_sleep.wait_30_seconds] | ||
} | ||
|