Giter Site home page Giter Site logo

Sentry issue alert conditions, filters, and actions in JSON string format reduce the usability and maintainability of the code about terraform-provider-sentry HOT 2 OPEN

ryanbratten avatar ryanbratten commented on June 17, 2024 5
Sentry issue alert conditions, filters, and actions in JSON string format reduce the usability and maintainability of the code

from terraform-provider-sentry.

Comments (2)

jianyuan avatar jianyuan commented on June 17, 2024

Hello @ryanbratten, thank you for your suggestion. I value your input. I chose the JSON approach primarily due to the diverse nature of the configuration items. For instance, for the same property name, the value can vary between a string and an integer, depending on the type of configuration item. Take targetIdentifier as an example. According to the documentation:

targetIdentifier: The ID of the target. This must be an integer for PagerDuty and Sentry apps, and a string for all others. Examples of appropriate values include a Slack channel name (#my-channel), a user ID, a team ID, a Sentry app ID, etc.

Due to Terraform's limitations, it's impractical to use the same property name for a union type (e.g., string and integer). Consequently, we would need to name these properties explicitly, such as pageduty_id, sentry_app_id, etc., with the appropriate types.

Alternatively, we could consider creating a data source for each condition, filter, and action that outputs JSON. A prime example is AWS's iam_policy_document, which generates a policy JSON that can be used with iam_policy.policy. We could adopt a similar approach and not introduce another incompatible change. Whenever a new configuration item is introduced, users can manually create the JSON and immediately use the new functionality while the data source that generates the JSON can be developed.

For the time being, I recommend using Terraform's jsonencode() function to construct your JSON. In your case, you can utilize Terraform arrays with jsonencode() to maintain HCL highlighting and facilitate the translation of Terraform language into JSON effectively. However, take extra care as HCL is unable to distinguish between an integer and a float.

actions = jsonencode([
    for channel in var.slack_channels:
    {
      id        = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
      channel   = channel
      workspace = data.sentry_organization_integration.slack.internal_id
    }
])

I hope this helps!

from terraform-provider-sentry.

strugee avatar strugee commented on June 17, 2024

For the time being, I recommend using Terraform's jsonencode() function to construct your JSON.

Note that the docs say to avoid jsonencode() due to the int/float problem: https://registry.terraform.io/providers/jianyuan/sentry/latest/docs/resources/issue_alert

Are you suggesting that parseint() can make this safe? I'm also unclear on how that's even a problem because I can't imagine floats are being used as identifiers (and JSON itself also cannot distinguish between ints and floats)?

from terraform-provider-sentry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.