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

Missing "round robin" argument

Open mjimeneznet opened this issue 2 years ago • 2 comments

Terraform Version

Terraform v1.1.7
on linux_amd64
+ provider registry.terraform.io/hashicorp/external v2.2.2
+ provider registry.terraform.io/hashicorp/vault v3.5.0
+ provider registry.terraform.io/pagerduty/pagerduty v2.4.1

Affected Resource(s)

Please list the resources as a list, for example:

  • pagerduty_escalation_policy

Expected Behavior

I'm missing the option to set "round robin" as I can do in the UI for the escalation policy

Actual Behavior

We don't have the option to set "round robin" therefore if you create a escalation policy in Terraform you still have to go to UI to set the "round robin".

mjimeneznet avatar Jun 02 '22 09:06 mjimeneznet

+ 1 to this since right now it prevents us from managing escalation policies in Terraform.

aelmekeev avatar Aug 14 '22 10:08 aelmekeev

+1 to this, it would be very helpful for our team

michaljmatusiak92 avatar Oct 12 '22 12:10 michaljmatusiak92

+1 would be super helpful for our team 🙏🙏🙏

lydiamnash avatar Dec 03 '22 00:12 lydiamnash

+1

kratux avatar Dec 09 '22 22:12 kratux

+1

ericturcotte avatar Dec 21 '22 20:12 ericturcotte

+1

RATANAJANGIR avatar Feb 22 '23 09:02 RATANAJANGIR

+1

neekolas avatar Feb 22 '23 16:02 neekolas

+1

liammac avatar May 19 '23 15:05 liammac

+1

mattbates-CP avatar May 24 '23 17:05 mattbates-CP

I'd be happy to take this one on and provide a PR 🎉

Crevil avatar Jun 02 '23 17:06 Crevil

Also have a need for enabling Round Robin in escalation policies from Terraform. This is blocking some adoption in my organization.

Here is my workaround using a Null Provider

# Activate Round Robin Scheduling for first layer in Escalation Policy
resource "null_resource" "pagerduty_round_robin_scheduling" {
  count = var.service.roundrobin_scheduling == true ? 1 : 0

  triggers = {
    escalation_policy_id = pagerduty_escalation_policy.this.id,
  }

  provisioner "local-exec" {
    command = <<EOT
    set -e ; \
    TARGET_ID=$(curl -s 'https://api.pagerduty.com/escalation_policies/${self.triggers.escalation_policy_id}?include[]=escalation_rule_assignment_strategies' \
      --header "Authorization: Token token=$TF_VAR_pagerduty_token" \
      --header 'Accept: application/vnd.pagerduty+json;version=2' \
      --header 'Content-Type: application/json' \
      --request GET | jq '. | .escalation_policy.escalation_rules[0].escalation_rule_assignment_strategy.type = "round_robin"') ; \
    curl -s 'https://api.pagerduty.com/escalation_policies/${self.triggers.escalation_policy_id}?include[]=escalation_rule_assignment_strategies' \
      --header "Authorization: Token token=$TF_VAR_pagerduty_token" \
      --header 'Accept: application/vnd.pagerduty+json;version=2' \
      --header 'Content-Type: application/json' \
      --request PUT \
      --data "$TARGET_ID"
EOT
  }

  provisioner "local-exec" {
    when    = destroy
    command = <<-EOT
     TARGET_ID=$(curl -s 'https://api.pagerduty.com/escalation_policies/${self.triggers.escalation_policy_id}?include[]=escalation_rule_assignment_strategies' \
      --header "Authorization: Token token=$TF_VAR_pagerduty_token" \
      --header 'Accept: application/vnd.pagerduty+json;version=2' \
      --header 'Content-Type: application/json' \
      --request GET | jq '. | .escalation_policy.escalation_rules[0].escalation_rule_assignment_strategy.type = "assign_to_everyone"') ; \
    curl -s 'https://api.pagerduty.com/escalation_policies/${self.triggers.escalation_policy_id}?include[]=escalation_rule_assignment_strategies' \
      --header "Authorization: Token token=$TF_VAR_pagerduty_token" \
      --header 'Accept: application/vnd.pagerduty+json;version=2' \
      --header 'Content-Type: application/json' \
      --request PUT \
      --data "$TARGET_ID"
EOT
  }

  depends_on = [pagerduty_escalation_policy.this]
}

BillSidney avatar Jun 27 '23 15:06 BillSidney

Is there any progress on adding this to the provider? I've got teams wanting this feature.

BillSidney avatar Sep 06 '23 15:09 BillSidney

Also have a need for enabling Round Robin in escalation policies from Terraform. This is blocking some adoption in my organization.

Here is my workaround using a Null Provider

# Activate Round Robin Scheduling for first layer in Escalation Policy
resource "null_resource" "pagerduty_round_robin_scheduling" {
  count = var.service.roundrobin_scheduling == true ? 1 : 0

  triggers = {
    escalation_policy_id = pagerduty_escalation_policy.this.id,
  }

  provisioner "local-exec" {
    command = <<EOT
    set -e ; \
    TARGET_ID=$(curl -s 'https://api.pagerduty.com/escalation_policies/${self.triggers.escalation_policy_id}?include[]=escalation_rule_assignment_strategies' \
      --header "Authorization: Token token=$TF_VAR_pagerduty_token" \
      --header 'Accept: application/vnd.pagerduty+json;version=2' \
      --header 'Content-Type: application/json' \
      --request GET | jq '. | .escalation_policy.escalation_rules[0].escalation_rule_assignment_strategy.type = "round_robin"') ; \
    curl -s 'https://api.pagerduty.com/escalation_policies/${self.triggers.escalation_policy_id}?include[]=escalation_rule_assignment_strategies' \
      --header "Authorization: Token token=$TF_VAR_pagerduty_token" \
      --header 'Accept: application/vnd.pagerduty+json;version=2' \
      --header 'Content-Type: application/json' \
      --request PUT \
      --data "$TARGET_ID"
EOT
  }

  provisioner "local-exec" {
    when    = destroy
    command = <<-EOT
     TARGET_ID=$(curl -s 'https://api.pagerduty.com/escalation_policies/${self.triggers.escalation_policy_id}?include[]=escalation_rule_assignment_strategies' \
      --header "Authorization: Token token=$TF_VAR_pagerduty_token" \
      --header 'Accept: application/vnd.pagerduty+json;version=2' \
      --header 'Content-Type: application/json' \
      --request GET | jq '. | .escalation_policy.escalation_rules[0].escalation_rule_assignment_strategy.type = "assign_to_everyone"') ; \
    curl -s 'https://api.pagerduty.com/escalation_policies/${self.triggers.escalation_policy_id}?include[]=escalation_rule_assignment_strategies' \
      --header "Authorization: Token token=$TF_VAR_pagerduty_token" \
      --header 'Accept: application/vnd.pagerduty+json;version=2' \
      --header 'Content-Type: application/json' \
      --request PUT \
      --data "$TARGET_ID"
EOT
  }

  depends_on = [pagerduty_escalation_policy.this]
}

Building on the workaround from @BillSidney. Instead of only applying when the id of the escalation policy changes I trigger it every time anything in the escalation policy changes. Like this:

triggers = {
    escalation_policy_state = sha1(jsonencode({
      resource_state = pagerduty_escalation_policy.this
    }))
  }

tmablunar avatar Sep 29 '23 10:09 tmablunar

Hi @mjimeneznet support for Round Robin escalation rule assignment strategy for incident is now available from version v3.3.0. Thank you all for the patience and support 🎉 🥳

imjaroiswebdev avatar Dec 07 '23 22:12 imjaroiswebdev