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

Cloud Scheduler Takes Pubsub.topic_id not topic_name, make documentation clearer #5023

Closed
stanzheng opened this issue Nov 29, 2019 · 5 comments · Fixed by GoogleCloudPlatform/magic-modules#2904

Comments

@stanzheng
Copy link

stanzheng commented Nov 29, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • If an issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version 12.12

Affected Resource(s)

  • google_cloudscheduler

Terraform Configuration Files

resource "google_cloud_scheduler_job" "pub_sub_job" {
  depends_on  = ["null_resource.is_ready"]
  name        = "${var.name}"
  description = "${var.description}"
  schedule    = "${var.schedule}"
  time_zone   = "${var.time_zone}"
  region      = "${var.region}"

  pubsub_target {
    topic_name = "${var.topic_id}"  # accepts pubsub.topic_id
    data         = "${base64encode(var.data)}"
  }
  
  count = "${(var.env == "dev" && var.is_dev) || (var.env == "qa" && var.is_qa) || (var.env == "prod" && var.is_prod) ? 1 : 0}"
}

Debug Output

Panic Output

Expected Behavior

SUCCESS APPLY

Actual Behavior

Error: Error creating Job: googleapi: Error 400: Topic dev-cloudscheduler_function_ctfycloud_pam should be in the format "projects/<PROJECT_ID>/topics/<TOPIC_ID>".

Steps to Reproduce

  1. terraform apply

Important Factoids

Cloud Scheduler parameter suggests takes a pubsub.topic_name but instead takes a pubsub_topic_id.

Documentation should be updated that Example Usage - Scheduler Job Pubsub for pubsub_target should take a topic_id not topic_name

References

https://www.terraform.io/docs/providers/google/r/cloud_scheduler_job.html#topic_name

  • #0000
@ghost ghost added the bug label Nov 29, 2019
@venkykuberan venkykuberan self-assigned this Dec 26, 2019
@venkykuberan
Copy link
Contributor

venkykuberan commented Dec 27, 2019

@szheng-nyc3,
The documentation says what's the expected format for the topic_name property for cloud_scheduler resource. With this way we can refer any topics external to your config.

topic_name - (Required) The name of the Cloud Pub/Sub topic to which messages 
will be published when a job is delivered. The topic name must be in the same format 
as required by PubSub's PublishRequest.name,
for example projects/PROJECT_ID/topics/TOPIC_ID

Actually its inline with what we see on the cloud console

Topic name - projects/xxx/topics/test-topic

@stanzheng
Copy link
Author

stanzheng commented Dec 27, 2019

so i think i might have been unclear on my example

this was a while back but i think this was the issue

for a pubsub topic resource named for example topic

google_pubsub_topic.topic.id != google_pubsub_topic.topic.name

and i was using the later to pass into the cloudscheduler because the param was topic.name but was looking for topic.id.

  1. I think in this case the issue was these were not the same
  2. the cloudscheduler wanted id not what the meta suggests, topic_name.

if {topic_name=topic.id} this is intended this issue can be closed

@ghost ghost removed the waiting-response label Dec 27, 2019
@venkykuberan
Copy link
Contributor

We will add this item to documentation update list. Thank you

@emilymye
Copy link
Contributor

I can try to emphasize that it's the full resource name, but I'm not sure what else we can say. The documentation both states the expected full-path format for topic name and uses the correct interpolation in the example:

topic_name = {google_pubsub_topic.topic.id}

If you have a suggestion for what additional notes we can put into the docs to reduce confusion, I'm happy to hear it.

However, this ends up being a common problem, since name just means different things in Terraform and across each of the GCP APIs. We can't and wouldn't like to take on the maintanence burden of notes like "Don't use google_pubsub_topic.topic.name" everywhere, considering many resources in GCP differ in whether they want the full PubSub topic name vs short name (i.e. the Terraform name, if you'd like). We also can't change the field name to be topic_id, both because it's a breaking change and lot's of work to rename a field in Terraform, and because it might cause confusion in the other direction, since some users also look at the GCP API to determine what value to set and topic_id doesn't exist in GCP. We named it based on the field ("topic_name") in the GCP Job resource.

@ghost
Copy link

ghost commented Feb 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Feb 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants