From 21aef4335c65add1e1b54f66c22981ed5cc213a7 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Thu, 14 Dec 2023 15:51:57 -0800 Subject: [PATCH] Replace "Pubsub Subscription Different Project" example with making all examples cross-project-friendly (#9637) * Fix "Pubsub Subscription Different Project" example PR #2342 changed this example from using `id` to `name`, which removed the project ID from the topic. However, the point of this example is to show how to set up a cross-project subscription, so the example no longer works. This change reverts that change from PR #2342. Fixes hashicorp/terraform-provider-google#11642. Fixes hashicorp/terraform-provider-google#6024. * Make all examples cross-project-friendly and update topic description * Fix typo --------- Co-authored-by: Stephen Lewis (Burrows) --- mmv1/products/pubsub/Subscription.yaml | 13 +++---------- .../examples/pubsub_subscription_dead_letter.tf.erb | 2 +- .../pubsub_subscription_different_project.tf.erb | 10 ---------- .../examples/pubsub_subscription_pull.tf.erb | 2 +- .../examples/pubsub_subscription_push.tf.erb | 2 +- .../examples/pubsub_subscription_push_bq.tf.erb | 2 +- .../pubsub_subscription_push_cloudstorage.tf.erb | 2 +- ...ubsub_subscription_push_cloudstorage_avro.tf.erb | 2 +- 8 files changed, 9 insertions(+), 26 deletions(-) delete mode 100644 mmv1/templates/terraform/examples/pubsub_subscription_different_project.tf.erb diff --git a/mmv1/products/pubsub/Subscription.yaml b/mmv1/products/pubsub/Subscription.yaml index 1def915ef94c..c8db8edf8f1a 100644 --- a/mmv1/products/pubsub/Subscription.yaml +++ b/mmv1/products/pubsub/Subscription.yaml @@ -42,15 +42,6 @@ examples: vars: topic_name: 'example-topic' subscription_name: 'example-subscription' - - !ruby/object:Provider::Terraform::Examples - name: 'pubsub_subscription_different_project' - primary_resource_id: 'example' - skip_test: true - vars: - topic_name: 'example-topic' - topic_project: 'topic-project' - subscription_name: 'example-subscription' - subscription_project: 'subscription-project' - !ruby/object:Provider::Terraform::Examples name: 'pubsub_subscription_dead_letter' primary_resource_id: 'example' @@ -101,7 +92,9 @@ properties: resource: 'Topic' imports: 'name' description: | - A reference to a Topic resource. + A reference to a Topic resource, of the form projects/{project}/topics/{{name}} + (as in the id property of a google_pubsub_topic), or just a topic name if + the topic is in the same project as the subscription. required: true immutable: true pattern: 'projects/{{project}}/topics/{{topic}}' diff --git a/mmv1/templates/terraform/examples/pubsub_subscription_dead_letter.tf.erb b/mmv1/templates/terraform/examples/pubsub_subscription_dead_letter.tf.erb index e7274d16f004..f5b66321767d 100644 --- a/mmv1/templates/terraform/examples/pubsub_subscription_dead_letter.tf.erb +++ b/mmv1/templates/terraform/examples/pubsub_subscription_dead_letter.tf.erb @@ -8,7 +8,7 @@ resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>_dead_letter" { resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['subscription_name'] %>" - topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.name + topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id dead_letter_policy { dead_letter_topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>_dead_letter.id diff --git a/mmv1/templates/terraform/examples/pubsub_subscription_different_project.tf.erb b/mmv1/templates/terraform/examples/pubsub_subscription_different_project.tf.erb deleted file mode 100644 index 4bf08dfe2460..000000000000 --- a/mmv1/templates/terraform/examples/pubsub_subscription_different_project.tf.erb +++ /dev/null @@ -1,10 +0,0 @@ -resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" { - project = "<%= ctx[:vars]['topic_project'] %>" - name = "<%= ctx[:vars]['topic_name'] %>" -} - -resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" { - project = "<%= ctx[:vars]['subscription_project'] %>" - name = "<%= ctx[:vars]['subscription_name'] %>" - topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.name -} diff --git a/mmv1/templates/terraform/examples/pubsub_subscription_pull.tf.erb b/mmv1/templates/terraform/examples/pubsub_subscription_pull.tf.erb index 35e10f60bcb5..7daa29c14275 100644 --- a/mmv1/templates/terraform/examples/pubsub_subscription_pull.tf.erb +++ b/mmv1/templates/terraform/examples/pubsub_subscription_pull.tf.erb @@ -4,7 +4,7 @@ resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" { resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['subscription_name'] %>" - topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.name + topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id labels = { foo = "bar" diff --git a/mmv1/templates/terraform/examples/pubsub_subscription_push.tf.erb b/mmv1/templates/terraform/examples/pubsub_subscription_push.tf.erb index 690cbca6aa6e..631f19321888 100644 --- a/mmv1/templates/terraform/examples/pubsub_subscription_push.tf.erb +++ b/mmv1/templates/terraform/examples/pubsub_subscription_push.tf.erb @@ -4,7 +4,7 @@ resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" { resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['subscription_name'] %>" - topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.name + topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id ack_deadline_seconds = 20 diff --git a/mmv1/templates/terraform/examples/pubsub_subscription_push_bq.tf.erb b/mmv1/templates/terraform/examples/pubsub_subscription_push_bq.tf.erb index 9bc5915278d4..77866e8e0b65 100644 --- a/mmv1/templates/terraform/examples/pubsub_subscription_push_bq.tf.erb +++ b/mmv1/templates/terraform/examples/pubsub_subscription_push_bq.tf.erb @@ -4,7 +4,7 @@ resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" { resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['subscription_name'] %>" - topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.name + topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id bigquery_config { table = "${google_bigquery_table.test.project}.${google_bigquery_table.test.dataset_id}.${google_bigquery_table.test.table_id}" diff --git a/mmv1/templates/terraform/examples/pubsub_subscription_push_cloudstorage.tf.erb b/mmv1/templates/terraform/examples/pubsub_subscription_push_cloudstorage.tf.erb index 5f89e82f2cb1..e946dada186e 100644 --- a/mmv1/templates/terraform/examples/pubsub_subscription_push_cloudstorage.tf.erb +++ b/mmv1/templates/terraform/examples/pubsub_subscription_push_cloudstorage.tf.erb @@ -10,7 +10,7 @@ resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" { resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['subscription_name'] %>" - topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.name + topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id cloud_storage_config { bucket = google_storage_bucket.<%= ctx[:primary_resource_id] %>.name diff --git a/mmv1/templates/terraform/examples/pubsub_subscription_push_cloudstorage_avro.tf.erb b/mmv1/templates/terraform/examples/pubsub_subscription_push_cloudstorage_avro.tf.erb index 1692813943e5..8df2217e7b5a 100644 --- a/mmv1/templates/terraform/examples/pubsub_subscription_push_cloudstorage_avro.tf.erb +++ b/mmv1/templates/terraform/examples/pubsub_subscription_push_cloudstorage_avro.tf.erb @@ -10,7 +10,7 @@ resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" { resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['subscription_name'] %>" - topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.name + topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id cloud_storage_config { bucket = google_storage_bucket.<%= ctx[:primary_resource_id] %>.name