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

pagerduty_service does not rectify drift for alert_grouping_parameters.config.timeout #897

Open
camlow325 opened this issue Jul 2, 2024 · 0 comments

Comments

@camlow325
Copy link

If the timeout for alert_grouping_parameters for a service is updated outside of Terraform, a subsequent Terraform apply may not be able to reconcile the difference and update PagerDuty with the intended value.

Terraform Version

› terraform -v
Terraform v1.9.0
on darwin_arm64
+ provider registry.terraform.io/pagerduty/pagerduty v3.14.4

Affected Resource(s)

  • pagerduty_service

Terraform Configuration Files

resource "pagerduty_service" "service" {
  name                    = "test"
  description             = "test"
  auto_resolve_timeout    = 14400
  acknowledgement_timeout = 1800
  escalation_policy       = ...[omitted-for-brevity]...
  alert_creation          = "create_alerts_and_incidents"

  alert_grouping_parameters {
    type = "time"

    config {
      timeout = 60
    }
  }

  incident_urgency_rule {
    type    = "constant"
    urgency = "severity_based"
  }
}

Debug Output

Panic Output

Expected Behavior

Terraform plan shows that the timeout would be updated from 59 (currently in PagerDuty) back to 60 (in the Terraform code) and apply changes the value back to 60:

Terraform will perform the following actions:

  # pagerduty_service.service will be updated in-place
  ~ resource "pagerduty_service" "service" {
        id                      = "..."
        name                    = "test"
        # (12 unchanged attributes hidden)

      ~ alert_grouping_parameters {
            # (1 unchanged attribute hidden)

          ~ config {
              ~ timeout     = 59 -> 60
                # (3 unchanged attributes hidden)
            }
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

pagerduty_service.service: Modifying... [id=...]
pagerduty_service.service: Modifications complete after 1s [id=...]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Actual Behavior

Apply output shows the following:

pagerduty_service.service: Refreshing state... [id=...]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

A follow-up GET request to the PagerDuty API for the service shows that the timeout value remains 59 (set previously via the curl command) and not 60 (set in the Terraform code):

$ curl -v --request GET \
  --url https://api.pagerduty.com/services/[ID-of-service-created-by-Terraform] \
  --header 'Accept: application/json' \
  --header 'Authorization: Token token=...' \
  --header 'Content-Type: application/json'
{
  "service": {
    ...
    "alert_grouping": "time",
    "alert_grouping_timeout": 59,
    "alert_grouping_parameters": {
      "type": "time",
      "config": {
        "timeout": 59
      }
    },
    ...
} 

Steps to Reproduce

  1. terraform apply
  2. Store the JSON file below to a local file named test.json:
{
 "service": {
  "acknowledgement_timeout": 1800,
  "alert_creation": "create_alerts_and_incidents",
  "alert_grouping": "time",
  "alert_grouping_timeout": 59,
  "alert_grouping_parameters": {
   "type": "time",
   "config": {
    "timeout": 59,
    "aggregate": ""
   }
  },
  "auto_resolve_timeout": 14400,
  "description": "test",
  "escalation_policy": {
   "id": "...[omitted for brevity]...",
   "type": "escalation_policy_reference"
  },
  "incident_urgency_rule": {
   "type": "constant",
   "urgency": "severity_based"
  },
  "name": "test"
 }
}
  1. Terraform apply should be successful.
  2. Run the following command to update the timeout for the alert_grouping_parameters to 59:
$ curl -v --request PUT \
  --url https://api.pagerduty.com/services/[ID-of-service-created-by-Terraform] \
  --header 'Accept: application/json' \
  --header 'Authorization: Token token=...' \
  --header 'Content-Type: application/json' -d test.json
  1. API response should report that the timeout was updated to 59:
{
  "service": {
    ...
    "alert_grouping": "time",
    "alert_grouping_timeout": 59,
    "alert_grouping_parameters": {
      "type": "time",
      "config": {
        "timeout": 59
      }
    },
    ...
} 
  1. terraform apply

Important Factoids

References

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

1 participant