Skip to content

Can't create opsgenie_service_incident_rule : 422 response #454

Closed
@ppiotrlach

Description

@ppiotrlach

Terraform Version

  • opsgenie/opsgenie v0.6.37

Affected Resource(s)

  • opsgenie_service_incident_rule

Terraform Configuration Files

resource "opsgenie_service" "empty" {
  name = "Empty Service"
  description = "Terraform requires an associated service to create incident rules, unlike the Opsgenie GUI, which allows rule creation without a service. This service fulfills that requirement and serves as work-around to create such incident rules."
  team_id = data.opsgenie_team.team.id
}

resource "opsgenie_service_incident_rule" "manual_reports_rule" {
  service_id = opsgenie_service.empty.id
  incident_rule {
    condition_match_type = "match-all-conditions"
    conditions {
      field          = "priority"
      not            = false
      operation      = "equals"
      expected_value = "P1"
    }
    conditions {
      field          = "tags"
      not            = false
      operation      = "contains"
      expected_value = "manual"
    }

    incident_properties {
      message     = "{{message}}"
      description = "{{description}}"
      priority    = "P1"
      tags        = ["{{tags}}"]

      stakeholder_properties {
        message     = "{{message}}"
        description = "{{description}}"
        enable      = "true"
      }
    }
  }
}

Expected Behavior

New incident rule should be created.

Actual Behavior

opsgenie_service_incident_rule.manual_reports_rule: Creating...
╷
│ Error: Error occurred with Status code: 422, Message: Request body is not processable. Please check the errors., Took: 0.004000, RequestId: 2d0929fa-c74e-4cd6-9d4c-0f50729ed0de, Error Detail: map[incidentRule:Request property [incidentRule] may not be empty.]
│ 
│   with opsgenie_service_incident_rule.manual_reports_rule,
│   on incidentrules.tf line [91](https://gitlab.xxx.com/opsgenie/opsgenie-alerting/some-team/-/jobs/8390788#L91), in resource "opsgenie_service_incident_rule" "manual_reports_rule":
│   91: resource "opsgenie_service_incident_rule" "manual_reports_rule" {

I also have tried without some of optional fields but result was all the same.

Additional notes

I was updating multiple Opsgenie repositories across our organization with mentioned changes. MRs which were merged previous week were applied without issues, afterwards we started experiencing this issue. Seems like something have changed in Opsgenie API during this period?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions