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

Missing example for pub sub protobuf schema definition #10259

Closed
Assignees

Comments

@Talador12
Copy link

Talador12 commented Oct 5, 2021

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 the 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 the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

See here:
https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_topic#example-usage---pubsub-topic-schema-settings

The avro definition works but there is not an example for protobuf, and several valid schemas are getting

Error: Error creating Schema: googleapi: Error 400: Invalid schema definition: Could not parse schema.

It would help if there was a working example to branch off of. For instance, here is an example for both schema types:
https://cloud.google.com/pubsub/docs/publisher#using_schema

New or Affected Resource(s)

  • google_pubsub_schema

Potential Terraform Configuration

resource "google_pubsub_schema" "example" {
  name = "example"
  type = "PROTOCOL_BUFFER"
  definition = "syntax = \"proto3\";\nmessage Results {\nstring message_request = 1;\nstring message_response = 2;\nstring timestamp_request = 3;\nstring timestamp_response = 4;\n}"
}

resource "google_pubsub_topic" "example" {
  name = "example-topic"

  depends_on = [google_pubsub_schema.example]
  schema_settings {
    schema = "projects/my-project-name/schemas/example"
    encoding = "JSON"
  }
}

References

@megan07
Copy link
Contributor

megan07 commented Oct 13, 2021

Hi @Talador12 ! I'm sorry you're running into this issue. Is the configuration you provided above returning the Invalid schema definition error? That one seemed to work for me. Thanks!

@Talador12
Copy link
Author

I did get this working with the above schema, but the project was not being inferred as it is with my other modules. Adding

project = var.project_id

did the trick for me.

Either way - I would recommend providing an example of the protobuf alongside the avro example

@megan07
Copy link
Contributor

megan07 commented Oct 13, 2021

Ah, ok, thanks @Talador12! We can add the documentation. I'm mostly wondering how we should triage this, as you mentioned that several valid schemas are hitting that error. If I'm understanding correctly, the schemas weren't the problem, but the lack of documentation made it hard to figure out what was missing. Is that correct?

@Talador12
Copy link
Author

Talador12 commented Oct 13, 2021

Yes - the schema is typically in a separate .proto file so I had to find examples of it condensed into the resource definition to make sure I was building the proper structure. Providing an initial example in documentation would provide at least one working schema, so users can prove this google_pubsub_schema resource is working properly.

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.