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

opsgenie_notification_policy - policy order

Open zszia opened this issue 4 years ago • 1 comments

Hi there,

I have several notification policies and I don't see a way to change the policy order with terraform.

OpsGenie API is supporting this with the endpoint: https://api.opsgenie.com/v2/policies/:identifier/change-order

Here the link to documentation: https://docs.opsgenie.com/docs/alert-and-notification-policy-api#change-policy-order

With regards Andreas

zszia avatar Sep 21 '20 08:09 zszia

also waiting for fo this feature

here is a workaround

provisioner "local-exec" {
    when = create

    # "environment" used as workaround not to expose api key in ci output
    # we use tf 0.12
    environment = {
      KEY = var.opsgenie_api_key
    }

    command = <<EOT
      echo self
      if [ ! -z "${each.value.order}" ] && [ ! -z "$KEY" ]; then
        echo ${each.value.order}
        curl -X POST 'https://api.opsgenie.com/v2/policies/${self.id}/change-order?teamId=${opsgenie_team.this.id}' \
            --header "Authorization: GenieKey $KEY" \
            --header 'Content-Type: application/json' \
            -d'{
            "targetIndex":"${each.value.order}"
        }';
      fi
  EOT
  }

azhurbilo avatar Apr 15 '21 11:04 azhurbilo