diff --git a/mmv1/products/notebooks/Instance.yaml b/mmv1/products/notebooks/Instance.yaml index b5fb92b0c1b1..613c50d70fab 100644 --- a/mmv1/products/notebooks/Instance.yaml +++ b/mmv1/products/notebooks/Instance.yaml @@ -393,6 +393,7 @@ properties: The Compute Engine tags to add to instance. item_type: Api::Type::String default_from_api: true + diff_suppress_func: NotebooksInstanceTagsDiffSuppress - !ruby/object:Api::Type::KeyValuePairs name: 'metadata' description: | diff --git a/mmv1/templates/terraform/constants/notebooks_instance.go b/mmv1/templates/terraform/constants/notebooks_instance.go index 230d2aece282..b1c47a704ffa 100644 --- a/mmv1/templates/terraform/constants/notebooks_instance.go +++ b/mmv1/templates/terraform/constants/notebooks_instance.go @@ -3,8 +3,22 @@ var NotebooksInstanceProvidedScopes = []string{ "https://www.googleapis.com/auth/userinfo.email", } +var NotebooksInstanceProvidedTags = []string{ + "deeplearning-vm", + "notebook-instance", +} + func NotebooksInstanceScopesDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { - old, new := d.GetChange("service_account_scopes") + return NotebooksDiffSuppressTemplate("service_account_scopes", NotebooksInstanceProvidedScopes, d) +} + +func NotebooksInstanceTagsDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { + return NotebooksDiffSuppressTemplate("tags", NotebooksInstanceProvidedTags, d) +} + +func NotebooksDiffSuppressTemplate(field string, defaults []string, d *schema.ResourceData) bool { + old, new := d.GetChange(field) + oldValue := old.([]interface{}) newValue := new.([]interface{}) oldValueList := []string{} @@ -17,7 +31,7 @@ func NotebooksInstanceScopesDiffSuppress(_, _, _ string, d *schema.ResourceData) for _, item := range newValue { newValueList = append(newValueList,item.(string)) } - newValueList= append(newValueList,NotebooksInstanceProvidedScopes...) + newValueList= append(newValueList,defaults...) sort.Strings(oldValueList) sort.Strings(newValueList) diff --git a/mmv1/templates/terraform/examples/notebook_instance_full.tf.erb b/mmv1/templates/terraform/examples/notebook_instance_full.tf.erb index 31f2af55ca3c..31de347bb0c6 100644 --- a/mmv1/templates/terraform/examples/notebook_instance_full.tf.erb +++ b/mmv1/templates/terraform/examples/notebook_instance_full.tf.erb @@ -34,6 +34,9 @@ resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" { "https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/userinfo.email" ] + + tags = ["foo", "bar"] + disk_encryption = "CMEK" kms_key = "<%= ctx[:vars]['key_name'] %>" desired_state = "ACTIVE"