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 import misses alert_grouping_parameters and auto_pause_notifications_parameters #626

Closed
modwyer42 opened this issue Feb 9, 2023 · 1 comment · Fixed by #673

Comments

@modwyer42
Copy link

Terraform Version

Terraform v1.3.7

  • provider registry.terraform.io/pagerduty/pagerduty v2.9.3

Affected Resource(s)

  • pagerduty_service

Terraform Configuration Files

Providing a cut down equivalent of the actual module, so it just has the resources required to reproduce.

resource "pagerduty_user" "bugdemo" {
  name  = "Bug Demo"
  email = "bugdemo@here.com"
}

resource "pagerduty_escalation_policy" "bugdemo" {
  name = "reproduce_bug"

  rule {
    escalation_delay_in_minutes = 15
    target {
      id   = pagerduty_user.bugdemo.id
      type = "user_reference"
    }
  }
}

resource "pagerduty_service" "bugdemo" {
  name              = "reproduce_bug"
  description       = "Sample service to reproduce import bug."
  escalation_policy = pagerduty_escalation_policy.bugdemo.id
  alert_creation    = "create_alerts_and_incidents"

  alert_grouping_parameters {
    type = "content_based"
    config {
      aggregate = "all"
      fields    = ["custom_details.accountId"]
    }
  }

  auto_pause_notifications_parameters {
    enabled = true
    timeout = 900
  }
}

Debug Output

Can provide if necessary, but reproduction of the issue is trivial.

Expected Behavior

When importing an existing PagerDuty service that is configured with alert_grouping_parameters and/or auto_pause_notifications_parameters values, these configured values should be imported in to the Terraform state.

Actual Behavior

The import completes successfully, but there is no state data relating to either alert_grouping_parameters or auto_pause_notifications_parameters configurations.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Ensure an existing service is configured in PagerDuty with Alert-grouping and Auto-pause enabled. (Can use the Terraform code above to deploy this and then just use terraform state rm <resource address> to remove it from the state.
    image

  2. Get the service ID from the services Web URL or from the API:

    GET https://api.pagerduty.com/services HTTP/1.1
    Content-Type: application/json
    Authorization: Token token="<token>"

    You can also verify the service configuration to import using:

    GET https://api.pagerduty.com/services/<serviceID>?include[]=auto_pause_notifications_parameters HTTP/1.1
    Content-Type: application/json
    Authorization: Token token="<token>"
  3. Run terraform import 'pagerduty_service.bugdemo' "<service ID>"

  4. Run terraform state show 'pagerduty_service.bugdemo' and confirm the missing configuration blocks.

  5. Run terraform plan -out="terraform.tfplan" to see the additional grouping/pause configurations Terraform expects to apply.

  6. Run terraform apply "terraform.tfplan" to reapply the configuration and correct the issue with state.

  7. Re-run terraform state show 'pagerduty_service.bugdemo' and confirm the expected configuration blocks are all present.

@imjaroiswebdev
Copy link
Contributor

@modwyer42 A patch for solving is now available on version v2.12.1 of PagerDuty Terraform Provider. Therefore, I encourage you to do the upgrade and if you still face the issue, pleas don't hesitate on re-opening this issue ✌🏽 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants