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.
refactor: update resource manager tag references
Update resource manager tag references in terraform code templates and some minor formatting changes - Update the code to use foo.id vs "tagKeys/${foo.name}" or "tagValues/${foo.name}", and foo.namespaced_name vs. "${data.google_project.project.project_id}/${foo.short_name}" - Wrap map keys in parens where needed. Followup to GoogleCloudPlatform#12118
- Loading branch information
Showing
13 changed files
with
124 additions
and
124 deletions.
There are no files selected for viewing
23 changes: 11 additions & 12 deletions
23
mmv1/templates/terraform/examples/bigquery_dataset_resource_tags.tf.tmpl
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 |
---|---|---|
@@ -1,34 +1,33 @@ | ||
data "google_project" "project" { | ||
} | ||
data "google_project" "project" {} | ||
|
||
resource "google_tags_tag_key" "tag_key1" { | ||
parent = "projects/${data.google_project.project.number}" | ||
parent = data.google_project.project.id | ||
short_name = "{{index $.Vars "tag_key1"}}" | ||
} | ||
|
||
resource "google_tags_tag_value" "tag_value1" { | ||
parent = "tagKeys/${google_tags_tag_key.tag_key1.name}" | ||
parent = google_tags_tag_key.tag_key1.id | ||
short_name = "{{index $.Vars "tag_value1"}}" | ||
} | ||
|
||
resource "google_tags_tag_key" "tag_key2" { | ||
parent = "projects/${data.google_project.project.number}" | ||
parent = data.google_project.project.id | ||
short_name = "{{index $.Vars "tag_key2"}}" | ||
} | ||
|
||
resource "google_tags_tag_value" "tag_value2" { | ||
parent = "tagKeys/${google_tags_tag_key.tag_key2.name}" | ||
parent = google_tags_tag_key.tag_key2.id | ||
short_name = "{{index $.Vars "tag_value2"}}" | ||
} | ||
|
||
resource "google_bigquery_dataset" "{{$.PrimaryResourceId}}" { | ||
dataset_id = "{{index $.Vars "dataset_id"}}" | ||
friendly_name = "test" | ||
description = "This is a test description" | ||
location = "EU" | ||
dataset_id = "{{index $.Vars "dataset_id"}}" | ||
friendly_name = "test" | ||
description = "This is a test description" | ||
location = "EU" | ||
|
||
resource_tags = { | ||
"${data.google_project.project.project_id}/${google_tags_tag_key.tag_key1.short_name}" = "${google_tags_tag_value.tag_value1.short_name}" | ||
"${data.google_project.project.project_id}/${google_tags_tag_key.tag_key2.short_name}" = "${google_tags_tag_value.tag_value2.short_name}" | ||
(google_tags_tag_key.tag_key1.id) = google_tags_tag_value.tag_value1.id | ||
(google_tags_tag_key.tag_key2.id) = google_tags_tag_value.tag_value2.id | ||
} | ||
} |
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
136 changes: 68 additions & 68 deletions
136
mmv1/templates/terraform/examples/dlp_discovery_config_actions.tf.tmpl
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 |
---|---|---|
@@ -1,96 +1,96 @@ | ||
resource "google_data_loss_prevention_discovery_config" "{{$.PrimaryResourceId}}" { | ||
parent = "projects/{{index $.TestEnvVars "project"}}/locations/us" | ||
location = "us" | ||
status = "RUNNING" | ||
parent = "projects/{{index $.TestEnvVars "project"}}/locations/us" | ||
location = "us" | ||
status = "RUNNING" | ||
|
||
targets { | ||
big_query_target { | ||
filter { | ||
other_tables {} | ||
} | ||
} | ||
targets { | ||
big_query_target { | ||
filter { | ||
other_tables {} | ||
} | ||
} | ||
actions { | ||
export_data { | ||
profile_table { | ||
project_id = "project" | ||
dataset_id = "dataset" | ||
table_id = "table" | ||
} | ||
} | ||
} | ||
actions { | ||
export_data { | ||
profile_table { | ||
project_id = "project" | ||
dataset_id = "dataset" | ||
table_id = "table" | ||
} | ||
} | ||
actions { | ||
pub_sub_notification { | ||
topic = "projects/%{project}/topics/${google_pubsub_topic.{{$.PrimaryResourceId}}.name}" | ||
event = "NEW_PROFILE" | ||
pubsub_condition { | ||
expressions { | ||
logical_operator = "OR" | ||
conditions { | ||
minimum_sensitivity_score = "HIGH" | ||
} | ||
} | ||
} | ||
detail_of_message = "TABLE_PROFILE" | ||
} | ||
actions { | ||
pub_sub_notification { | ||
topic = "projects/%{project}/topics/${google_pubsub_topic.{{$.PrimaryResourceId}}.name}" | ||
event = "NEW_PROFILE" | ||
pubsub_condition { | ||
expressions { | ||
logical_operator = "OR" | ||
conditions { | ||
minimum_sensitivity_score = "HIGH" | ||
} | ||
} | ||
} | ||
detail_of_message = "TABLE_PROFILE" | ||
} | ||
actions { | ||
tag_resources { | ||
tag_conditions { | ||
tag { | ||
namespaced_value = "123456/environment/prod" | ||
} | ||
sensitivity_score { | ||
score = "SENSITIVITY_HIGH" | ||
} | ||
} | ||
tag_conditions { | ||
tag { | ||
namespaced_value = "123456/environment/test" | ||
} | ||
sensitivity_score { | ||
score = "SENSITIVITY_LOW" | ||
} | ||
} | ||
profile_generations_to_tag = ["PROFILE_GENERATION_NEW", "PROFILE_GENERATION_UPDATE"] | ||
lower_data_risk_to_low = true | ||
} | ||
actions { | ||
tag_resources { | ||
tag_conditions { | ||
tag { | ||
namespaced_value = "123456/environment/prod" | ||
} | ||
sensitivity_score { | ||
score = "SENSITIVITY_HIGH" | ||
} | ||
} | ||
tag_conditions { | ||
tag { | ||
namespaced_value = "123456/environment/test" | ||
} | ||
sensitivity_score { | ||
score = "SENSITIVITY_LOW" | ||
} | ||
} | ||
profile_generations_to_tag = ["PROFILE_GENERATION_NEW", "PROFILE_GENERATION_UPDATE"] | ||
lower_data_risk_to_low = true | ||
} | ||
inspect_templates = ["projects/%{project}/inspectTemplates/${google_data_loss_prevention_inspect_template.basic.name}"] | ||
} | ||
inspect_templates = ["projects/%{project}/inspectTemplates/${google_data_loss_prevention_inspect_template.basic.name}"] | ||
} | ||
|
||
resource "google_pubsub_topic" "{{$.PrimaryResourceId}}" { | ||
name = "fake-topic" | ||
name = "fake-topic" | ||
} | ||
|
||
resource "google_data_loss_prevention_inspect_template" "basic" { | ||
parent = "projects/{{index $.TestEnvVars "project"}}" | ||
description = "My description" | ||
display_name = "display_name" | ||
parent = "projects/{{index $.TestEnvVars "project"}}" | ||
description = "My description" | ||
display_name = "display_name" | ||
|
||
inspect_config { | ||
info_types { | ||
name = "EMAIL_ADDRESS" | ||
} | ||
inspect_config { | ||
info_types { | ||
name = "EMAIL_ADDRESS" | ||
} | ||
} | ||
} | ||
|
||
data "google_project" "project" { | ||
project_id = "%{project}" | ||
project_id = "%{project}" | ||
} | ||
|
||
resource "google_tags_tag_key" "tag_key" { | ||
parent = "projects/${data.google_project.project.number}" | ||
short_name = "environment" | ||
parent = "projects/${data.google_project.project.number}" | ||
short_name = "environment" | ||
} | ||
|
||
resource "google_tags_tag_value" "tag_value" { | ||
parent = "tagKeys/${google_tags_tag_key.tag_key.name}" | ||
short_name = "prod" | ||
parent = google_tags_tag_key.tag_key.id | ||
short_name = "prod" | ||
} | ||
|
||
resource "google_project_iam_member" "tag_role" { | ||
project = "%{project}" | ||
role = "roles/resourcemanager.tagUser" | ||
member = "serviceAccount:service-${data.google_project.project.number}@dlp-api.iam.gserviceaccount.com" | ||
} | ||
project = "%{project}" | ||
role = "roles/resourcemanager.tagUser" | ||
member = "serviceAccount:service-${data.google_project.project.number}@dlp-api.iam.gserviceaccount.com" | ||
} |
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
25 changes: 13 additions & 12 deletions
25
mmv1/templates/terraform/examples/tag_binding_basic.tf.tmpl
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
resource "google_project" "project" { | ||
project_id = "{{index $.Vars "project_id"}}" | ||
name = "{{index $.Vars "project_id"}}" | ||
org_id = "{{index $.TestEnvVars "org_id"}}" | ||
deletion_policy = "DELETE" | ||
project_id = "{{index $.Vars "project_id"}}" | ||
name = "{{index $.Vars "project_id"}}" | ||
org_id = "{{index $.TestEnvVars "org_id"}}" | ||
|
||
deletion_policy = "DELETE" | ||
} | ||
|
||
resource "google_tags_tag_key" "key" { | ||
parent = "organizations/{{index $.TestEnvVars "org_id"}}" | ||
short_name = "{{index $.Vars "key_short_name"}}" | ||
description = "For {{index $.Vars "key_short_name"}} resources." | ||
parent = "organizations/{{index $.TestEnvVars "org_id"}}" | ||
short_name = "{{index $.Vars "key_short_name"}}" | ||
description = "For {{index $.Vars "key_short_name"}} resources." | ||
} | ||
|
||
resource "google_tags_tag_value" "value" { | ||
parent = "tagKeys/${google_tags_tag_key.key.name}" | ||
short_name = "{{index $.Vars "value_short_name"}}" | ||
description = "For {{index $.Vars "value_short_name"}} resources." | ||
parent = google_tags_tag_key.key.id | ||
short_name = "{{index $.Vars "value_short_name"}}" | ||
description = "For {{index $.Vars "value_short_name"}} resources." | ||
} | ||
|
||
resource "google_tags_tag_binding" "{{$.PrimaryResourceId}}" { | ||
parent = "//cloudresourcemanager.googleapis.com/projects/${google_project.project.number}" | ||
tag_value = "tagValues/${google_tags_tag_value.value.name}" | ||
parent = "//cloudresourcemanager.googleapis.com/projects/${google_project.project.number}" | ||
tag_value = google_tags_tag_value.value.id | ||
} |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
resource "google_tags_tag_key" "key" { | ||
parent = "organizations/{{index $.TestEnvVars "org_id"}}" | ||
short_name = "{{index $.Vars "key_short_name"}}" | ||
parent = "organizations/{{index $.TestEnvVars "org_id"}}" | ||
short_name = "{{index $.Vars "key_short_name"}}" | ||
description = "For {{index $.Vars "key_short_name"}} resources." | ||
} | ||
|
||
resource "google_tags_tag_value" "{{$.PrimaryResourceId}}" { | ||
parent = "tagKeys/${google_tags_tag_key.key.name}" | ||
short_name = "{{index $.Vars "value_short_name"}}" | ||
parent = google_tags_tag_key.key.id | ||
short_name = "{{index $.Vars "value_short_name"}}" | ||
description = "For {{index $.Vars "value_short_name"}} resources." | ||
} |
Oops, something went wrong.