opsgenie / terraform-provider-opsgenie

Terraform OpsGenie provider
https://registry.terraform.io/providers/opsgenie/opsgenie/latest/docs
Mozilla Public License 2.0
100 stars 135 forks source link

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

Open REBELinBLUE opened 9 months ago

REBELinBLUE commented 9 months ago

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

houseful-chisel commented 9 months ago

Also seeing this. terraform_version 1.6.3, opsgenie provider version 0.6.34

REBELinBLUE commented 9 months ago

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

mouhsen-ibrahim commented 9 months ago

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

cloud-pharaoh commented 9 months ago

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

koushik-swaminathan commented 8 months ago

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

kpocius commented 8 months ago

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