terraform-provider-opsgenie
terraform-provider-opsgenie copied to clipboard
Error when using matches operation in opsgenie_integration_action filter block for Priority filter field
Terraform Version
1.0.3
Affected Resource(s)
- opsgenie_integration_action filter block
Terraform Configuration Files
resource "opsgenie_integration_action" "jira_service_desk_create_action" {
integration_id = opsgenie_api_integration.jira_service_desk_create.id
create {
name = "Create Critical Alerts"
priority = "P1"
alert_actions = []
alias = "{{alias}}"
description = {{description}}
message = {{summary}}
source = "JiraServiceDesk"
user = "JiraServiceDesk"
filter {
type = "match-all-conditions"
conditions {
field = "issue_type"
operation = "matches"
expected_value = ".*Issue.*"
}
conditions {
field = "priority"
operation = "matches"
expected_value = ".*Critical.*"
}
}
responders {
id = "${opsgenie_team.team.id}"
type = "team"
}
}
}
Debug Output
Plan runs successfully with output below but apply fails with error.
+ create {
+ alert_actions = []
+ alias = "{{alias}}"
+ append_attachments = true
+ description = {{description}}
+ entity = "{{entity}}"
+ ignore_alert_actions_from_payload = true
+ ignore_extra_properties_from_payload = true
+ ignore_responders_from_payload = true
+ ignore_tags_from_payload = true
+ ignore_teams_from_payload = false
+ message = "{{summary}}"
+ name = "Create Critical Alerts"
+ note = "{{note}}"
+ order = 1
+ priority = "P1"
+ source = "JiraServiceDesk"
+ type = "create"
+ user = "JiraServiceDesk"
+ filter {
+ type = "match-all-conditions"
+ conditions {
+ expected_value = ".*Issue.*"
+ field = "issue_type"
+ not = false
+ operation = "matches"
}
+ conditions {
+ expected_value = ".*Critical.*"
+ field = "priority"
+ not = false
+ operation = "matches"
}
}
}
Panic Output
None
Expected Behavior
Terraform apply should allow matches
operation in filter block for the priority filter, and expected_value
should be allowed to be set as any value. This is possible to do in the console.
Actual Behavior
Error output
|
│ Error: matches is not valid operation for priority
│
│ with opsgenie_integration_action.jira_service_desk_create_action,
│ on action-jira.tf line 994, in resource "opsgenie_integration_action" "jira_service_desk_create_action":
│ 994: resource "opsgenie_integration_action" "jira_service_desk_create_action" {
│
Using operation equals
instead of matches
gives a different error:
Error: for field priority expected value should be one of P1, P2, P3, P4, P5
In the Opsgenie console this filter field can be set as any value.
Steps to Reproduce
-
terraform apply
Important Factoids
None
References
None
Since nobody answered you, i will offer some answers. You cannot use Regex to obtain the Priority values. It will be better for you to set the priority using the customPriority/Priority field, mapped to P1,P2,P3,P4 or P5. See the allowed operations here
But i agree that this should be refactored since it is an incoming filter
This limitation does not make sense. I can do this perfectly fine in the UI.
When I add the block in Terraform, the apply fails.
conditions {
field = "priority"
operation = "matches"
expected_value = "P(1|2|3)"
}