terraform-provider-opsgenie icon indicating copy to clipboard operation
terraform-provider-opsgenie copied to clipboard

[BUG] Default routing rule always showing changes for fields which are not required

Open REBELinBLUE opened this issue 1 year ago • 6 comments

Terraform Version

1.6.3 (also tried on 1.5.3)

Affected Resource(s)

opsgenie_team_routing_rule

Terraform Configuration Files

resource "opsgenie_team_routing_rule" "default" {
  name       = "Default Routing Rule"
  team_id    = opsgenie_team.this.id
  is_default = true

  order = 0

  criteria {
    type = "match-all"
  }

  notify {
    id   = opsgenie_escalation.default.id
    type = "escalation"
  }
}

Expected Behavior

Applying this multiple times should not show a change each time

Actual Behavior

After applying this, a subsequent plan says this

  ~ resource "opsgenie_team_routing_rule" "default" {
        id         = "f8af6d51-da2c-437d-bf23-02661337aa63"
        name       = "Default Routing Rule"
      - timezone   = "Europe/London" -> null
        # (3 unchanged attributes hidden)

      - time_restriction {
          - restriction {
              - end_hour   = 0 -> null
              - end_min    = 0 -> null
              - start_hour = 0 -> null
              - start_min  = 0 -> null
            }
        }

        # (2 unchanged blocks hidden)
    }

So I think well the API must be adding those, so I add to the terraform so it becomes

resource "opsgenie_team_routing_rule" "default" {
  name       = "Default Routing Rule"
  team_id    = opsgenie_team.this.id
  is_default = true

  order = 0

  criteria {
    type = "match-all"
  }

  notify {
    id   = opsgenie_escalation.default.id
    type = "escalation"
  }

  timezone = "Europe/London"

  time_restriction {
    restriction {
      end_hour   = 0
      end_min    = 0
      start_hour = 0
      start_min  = 0
    }
  }
}

and then apply but then get

│ Error: Missing required argument
│ 
│   on routing_rules.tf line 20, in resource "opsgenie_team_routing_rule" "default":
│   20:   time_restriction {
│ 
│ The argument "type" is required, but no definition was found.

so I add the type = "time-of-day" to the time_restriction but then get

╷
│ Error: Error occurred with Status code: 422, Message: Default routing rule can not be restricted to any time interval., Took: 0.008000, RequestId: 9d752b1b-4e93-41cf-8937-5578a03d4344
│ 
│   with opsgenie_team_routing_rule.default,
│   on routing_rules.tf line 1, in resource "opsgenie_team_routing_rule" "default":
│    1: resource "opsgenie_team_routing_rule" "default" {
│ 
╵

So there doesn't seem to be a way to manage reliably the default rule

REBELinBLUE avatar Nov 10 '23 15:11 REBELinBLUE

Also seeing this. terraform_version 1.6.3, opsgenie provider version 0.6.34

houseful-chisel avatar Nov 23 '23 16:11 houseful-chisel

For now I have "worked around" it with ignore_changes although obviously that isn't a brilliant solution

REBELinBLUE avatar Nov 23 '23 17:11 REBELinBLUE

I'm having the same issue with terraform version v1.5.7 and opsGenie provider v0.6.34, for now I'm ignoring the changes in the plan, if I downgrade to version v0.6.33 of the provider the changes are gone

mouhsen-ibrahim avatar Nov 27 '23 10:11 mouhsen-ibrahim

We are having the same issue with provider version 0.6.34 and TF version 1.5.7

cloud-pharaoh avatar Dec 01 '23 23:12 cloud-pharaoh

@REBELinBLUE will take a look at this issue, thank you!

koushik-swaminathan avatar Dec 20 '23 09:12 koushik-swaminathan

Looks like the issue got fixed via https://github.com/opsgenie/terraform-provider-opsgenie/pull/413

kpocius avatar Jan 02 '24 10:01 kpocius