Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace "Pubsub Subscription Different Project" example with making all examples cross-project-friendly #9637

Merged
merged 3 commits into from
Dec 14, 2023

Conversation

glasser
Copy link
Contributor

@glasser glasser commented Dec 13, 2023

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 removes that example and uses the id pattern on all the examples, because we don't need a special "cross project" example if the default usage works cross-project. It also expands the topic attribute's description.

Fixes hashicorp/terraform-provider-google#11642.
Fixes hashicorp/terraform-provider-google#6024.

Release Note Template for Downstream PRs (will be copied)


PR GoogleCloudPlatform#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 GoogleCloudPlatform#2342.

Fixes hashicorp/terraform-provider-google#11642.
Fixes hashicorp/terraform-provider-google#6024.
@modular-magician
Copy link
Collaborator

Hello! I am a robot. It looks like you are a: Community Contributor Googler Core Contributor. Tests will require approval to run.

@melinath, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Dec 13, 2023
Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've actually flipped positions on the question of name vs id and now prefer id in all cases; would you be willing to update the other pubsub subscription examples as well?

@@ -6,5 +6,5 @@ resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" {
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
topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure this works as expected, could you extend the example to include setting up a second that's being accessed and remove skip_test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure what you mean by "a second" here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, yeah, that sentence is incomprehensible - sorry about that! I meant a second project. If we were running this as a test, we'd want to make sure that we were actually setting up a second project (in addition to the default test project) and that the topic was in the other project. Currently the example uses topic-project but doesn't actually create that project.

But as you pointed out, if the rest of the pubsub documentation uses .id consistently, then cross-project doesn't need to be documented at all since it won't work differently than the other cases.

Copy link
Contributor Author

@glasser glasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow your overall suggestion. Are you saying you just think the docs should only document using id rather than name? In that case it probably doesn't need to have this example at all (but maybe the text of the topic option documentation could mention that while you can provide a short name, it's preferred to provide a full id and the latter is necessary for cross-project subscriptions)?

@@ -6,5 +6,5 @@ resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" {
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
topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure what you mean by "a second" here.

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to say it explicitly - it seems like it would make sense to remove this example altogether and update the remaining google_pubsub_subscription examples to use .id instead of .name - would you be down to make that change?

@glasser glasser changed the title Fix "Pubsub Subscription Different Project" example Replace "Pubsub Subscription Different Project" example with making all examples cross-rpoject-friendly Dec 14, 2023
@glasser glasser changed the title Replace "Pubsub Subscription Different Project" example with making all examples cross-rpoject-friendly Replace "Pubsub Subscription Different Project" example with making all examples cross-project-friendly Dec 14, 2023
@glasser
Copy link
Contributor Author

glasser commented Dec 14, 2023

OK, how's this look?

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good apart from one typo.

@modular-magician modular-magician added service/pubsub and removed awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests labels Dec 14, 2023
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 18 insertions(+), 29 deletions(-))
Terraform Beta: Diff ( 3 files changed, 18 insertions(+), 29 deletions(-))
TF OiCS: Diff ( 6 files changed, 6 insertions(+), 6 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3293
Passed tests 2955
Skipped tests: 337
Affected tests: 1

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccDataprocClusterIamPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataprocClusterIamPolicy[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@melinath melinath merged commit b3ae8dc into GoogleCloudPlatform:main Dec 14, 2023
13 checks passed
kapreus pushed a commit to kapreus/magic-modules that referenced this pull request Jan 2, 2024
…ll examples cross-project-friendly (GoogleCloudPlatform#9637)

* Fix "Pubsub Subscription Different Project" example

PR GoogleCloudPlatform#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 GoogleCloudPlatform#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]>
balanaguharsha pushed a commit to balanaguharsha/magic-modules that referenced this pull request May 2, 2024
…ll examples cross-project-friendly (GoogleCloudPlatform#9637)

* Fix "Pubsub Subscription Different Project" example

PR GoogleCloudPlatform#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 GoogleCloudPlatform#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants