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

Bug in sentry_notification_action resource that produced inconsistent result after apply #392

Open
bartoszbetkababylon opened this issue Feb 26, 2024 · 1 comment

Comments

@bartoszbetkababylon
Copy link

bartoszbetkababylon commented Feb 26, 2024

Inconsistent terraform state

Example:

resource "sentry_project" "default" {
  organization = "my-organization"

  teams = ["my-first-team"]
  name  = "test-service"

  platform = "java"
}

# Create a notification action for the project
resource "sentry_notification_action" "default" {
  organization      = sentry_project.default.organization
  trigger_type      = "spike-protection"
  service_type      = "slack"
  integration_id    = "<sentry_integration_slack_id>"
  target_identifier = "<slack_channel_id>"
  target_display    = "#default"
  projects          = [sentry_project.default.id]
}

Error:

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to resource.sentry_notification_action.default, provider "provider[\"registry.terraform.io/jianyuan/sentry\"]" produced an unexpected new value: .projects[0]: was cty.StringVal("test-service"), but now cty.StringVal("").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

This causes the notification to be recreated each time with a terraform plan:

-/+ resource "sentry_notification_action" "this" {
      ~ id                = "1324235" -> (known after apply)
      ~ projects          = [
          - "",
          + "test-service",
        ]
        # (6 unchanged attributes hidden)
    }

Perhaps this is because the project attribute is a list of the project slugs, and the sentry api seems to show the project ID in the response? https://docs.sentry.io/api/alerts/create-a-spike-protection-notification-action/

Additional issue: One notification action for multiple project slugs

Example:

resource "sentry_project" "default" {
  organization = "my-organization"

  teams = ["my-first-team"]
  name  = "test-service"

  platform = "java"
}

resource "sentry_project" "default2" {
  organization = "my-organization"

  teams = ["my-first-team"]
  name  = "test-service2"

  platform = "java"
}

resource "sentry_notification_action" "default" {
  organization      = sentry_project.default.organization
  trigger_type      = "spike-protection"
  service_type      = "slack"
  integration_id    = "<sentry_integration_slack_id>"
  target_identifier = "<slack_channel_id>"
  target_display    = "#default"
  projects          = [sentry_project.default.id, sentry_project.default2.id]
}

Error:

Error: Client Error
│
│   with sentry_notification_action.this,
│   on main.tf line 19, in resource "sentry_notification_action" "this":
│   19: resource "sentry_notification_action" "this" {
│
│ Error creating notification action: POST https://sentry.io/api/0/organizations/test/notifications/actions/: 400 map[projects:[Each action for 'spike-protection' trigger must apply to one project]]
@clymerrm
Copy link

Has anyone found a way around this? I thought I had this working previously but now all of my runs to fail because of this.

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