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

Nested JSON items body_template in logzio_endpoint #70

Closed
Tenchi2xh opened this issue May 20, 2021 · 6 comments
Closed

Nested JSON items body_template in logzio_endpoint #70

Tenchi2xh opened this issue May 20, 2021 · 6 comments

Comments

@Tenchi2xh
Copy link

Tenchi2xh commented May 20, 2021

Hi ! I would like to do the following:

resource "logzio_endpoint" "pagerduty" {
  title         = "..."
  description   = "..."
  endpoint_type = "custom"

  custom {
    url    = "https://..."
    method = "POST"

    headers = {
      "Authorization" = "..."
      "Content-type"  = "application/json"
    }

    body_template = {
      "foo" = "..."
      "bar" = {
        "baz" = "..."
        "b4r" = "..."
      }
    }
  }
}

Since many endpoints have APIs which require nested objects, I am attempting to do that by nesting maps in maps for body_template.

However, the type of body_template is hard set to map of strings which renders this task impossible (manually JSON-encoding the nested objects will result in a double encode with escaped characters):

Inappropriate value for attribute "body_template": element "bar": string
required.

Would it be possible to change the type to string and let the users wrap the whole map with a jsonencode()? That would enable users to use real world APIs and also as an added benefit allow for integer and float types.

Thanks for your time

@Tenchi2xh
Copy link
Author

For now I will be forced to create some proxy that accepts a flattened version of the JSON object (where nested paths are represented with dots), unflattens it and proxies it to the destination API.

@mirii1994
Copy link
Contributor

Hi @Tenchi2xh thanks for the feedback, we will check this issue and try to fix it.
However, currently we don't have ETA for this.
If you want, you are welcome to create your own PR to fix this issue, and we'll review it :)

@mirii1994 mirii1994 mentioned this issue Aug 15, 2021
@mirii1994
Copy link
Contributor

@Tenchi2xh version 1.5.0 is out and should fix this issue.
You can see an example of how to use it here:
https://github.com/logzio/terraform-provider-logzio/blob/master/examples/alert_endpoint/main.tf#L30
Please let us know if this solves the issue :)

@mirii1994
Copy link
Contributor

Hi @Tenchi2xh did v1.5.0 fix the issue for you?

@mirii1994
Copy link
Contributor

@Tenchi2xh we're closing this issue, feel free to reopen if you have any further questions

@Tenchi2xh
Copy link
Author

Hi sorry for the late reply :) Unfortunately I moved on from that project and cannot test this anymore, but I hope this will help somebody else!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants