Skip to content

Commit

Permalink
Replace "Pubsub Subscription Different Project" example with making a…
Browse files Browse the repository at this point in the history
…ll 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) <[email protected]>
  • Loading branch information
glasser and melinath authored Dec 14, 2023
1 parent a080fd3 commit b3ae8dc
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 26 deletions.
13 changes: 3 additions & 10 deletions mmv1/products/pubsub/Subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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}}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b3ae8dc

Please sign in to comment.