PagerDuty / terraform-provider-pagerduty

Terraform PagerDuty provider
https://www.terraform.io/docs/providers/pagerduty/
Mozilla Public License 2.0
206 stars 210 forks source link

Support hours should be required in the plan if the incident_urgency_rule type is "use_support_hours" #843

Closed drastawi closed 4 months ago

drastawi commented 6 months ago

As per the documentation:

When using type = "use_support_hours" in incident_urgency_rule you must specify exactly one (otherwise optional) support_hours block.

This is currently not verified in the provider. I noticed people sometimes put the support hours inside the incident_urgency_rule by mistake and no error pops up during the plan.

Terraform Version

1.6.6

Affected Resource(s)

pagerduty_service

Terraform Configuration Files

resource "pagerduty_service" "foo" {
  name                    = "bar"
  description             = "bar bar bar"
  auto_resolve_timeout    = 3600
  acknowledgement_timeout = 3600
  escalation_policy       = pagerduty_escalation_policy.foo.id

  incident_urgency_rule {
    type = "use_support_hours"

    during_support_hours {
      type    = "constant"
      urgency = "high"
    }

    outside_support_hours {
      type    = "constant"
      urgency = "low"
    }
    support_hours {
      type         = "fixed_time_per_day"
      time_zone    = "America/Lima"
      start_time   = "09:00:00"
      end_time     = "17:00:00"
      days_of_week = [1, 2, 3, 4, 5]
    }
  }

Debug Output

shows plan

Panic Output

none

Expected Behavior

should panic and the API request will result in 400

Actual Behavior

shows plan

Steps to Reproduce

terraform plan