terraform-provider-pagerduty
terraform-provider-pagerduty copied to clipboard
Cannot create incident_workflow_trigger that executes on incident creation
The implementation of the pagerduty_incident_workflow_trigger
resource does not fully align to the API and prevents creation of triggers that execute on incident creation.
Web UI example of this trigger definition:
As per the API reference, in order to create a trigger that executes automatically on incident creation the condition
value must be set to an empty string (""
) with type set to conditional
.
The provider is not handling/nulling this empty string and so thinks that a condition was not provided, leading to it returning the error:
A direct API POST successfully configures the desired trigger when using the following payload:
{
"trigger_type": "conditional",
"workflow": {
"id": "PZXQRKC"
},
"services": [
{
"id": "PC9TV29"
}
],
"condition": ""
}
Terraform Version
Terraform v1.4.2 on linux_amd64
PagerDuty provider version: 2.11.2
Affected Resource(s)
- pagerduty_incident_workflow_trigger
Terraform Configuration Files
_Note:- Simplified configuration example provided.
terraform {
required_providers {
pagerduty = {
source = "pagerduty/pagerduty"
version = "~>2.9"
}
}
}
resource "pagerduty_incident_workflow" "example" {
name = "Example Incident Workflow"
description = "This Incident Workflow is an example"
step {
name = "Send Status Update"
action = "pagerduty.com:incident-workflows:send-status-update:1"
input {
name = "Message"
value = "Example status message sent on {{current_date}}"
}
}
}
resource "pagerduty_incident_workflow_trigger" "automatic_trigger" {
workflow = pagerduty_incident_workflow.example.id
type = "conditional"
condition = ""
subscribed_to_all_services = true
}
Debug Output
N/A
Expected Behavior
The provider should allow the explicit empty string to create an incident workflow trigger that executes on incident creation.
Actual Behavior
The provider is not handling/nulling this empty string and so thinks that a condition was not provided, leading to it returning the error:
Steps to Reproduce
- Create a
main.tf
using the above example. - Run
terraform init
- Run
terraform plan
The plan will error:
For anyone looking to workaround this in the meantime, you can get equivalent behaviour to "When an incident is created" using the following condition:
condition = "incident.status matches 'triggered'"
We have problem with this, in our case, using the last PD provider version 2.15.2
we're unable to fully create the incident workflow
Taking as example the code of this issue:
resource "pagerduty_incident_workflow" "example" {
name = "Example Incident Workflow"
description = "This Incident Workflow is an example"
step {
name = "Send Status Update"
action = "pagerduty.com:incident-workflows:send-status-update:1"
input {
name = "Message"
value = "Example status message sent on {{current_date}}"
}
}
}
This part is never configured on PD, and on each Terraform run it appears as new, it applies it but nothing in PagerDuty. This is a loop on each run. If we modify that in the UI it get replaced by an empty value each time that Terraform runs.
input {
name = "Message"
value = "Example status message sent on {{current_date}}"
}