terraform-provider-opsgenie
terraform-provider-opsgenie copied to clipboard
opsgenie_team_routing_rule `order` and `time_restriction` properties do not get imported properly
Terraform Version
0.12.24
Affected Resource(s)
Please list the resources as a list, for example:
- opsgenie_team_routing_rule
When importing an opsgenie_team_routing_rule, the time_restriction properties do not get reflected in the state. Also, the order property gets imported as null.
Terraform State
{
"mode": "managed",
"type": "opsgenie_team_routing_rule",
"name": "dev",
"provider": "provider.opsgenie",
"instances": [
{
"schema_version": 0,
"attributes": {
"criteria": [
{
"conditions": [
{
"expected_value": "development",
"field": "description",
"key": "",
"not": false,
"operation": "contains",
"order": 0
}
],
"type": "match-any-condition"
}
],
"id": "<GUID>",
"name": "Dev",
"notify": [
{
"id": "",
"name": "",
"type": "none"
}
],
"order": null,
"team_id": "<GUID>",
"time_restriction": [],
"timezone": "America/New_York"
}
}
]
}
Expected Behavior
All properties should get imported correctly.
Actual Behavior
- The
orderproperty does not reflect the value in OpsGenie - The
time_restrictionproperty is empty
Steps to Reproduce
- Create 2 or more Routing Rules in the OpsGenie UI with an ordering dependency and at least one with some time restrictions
- Import those routing rules into Terraform
- Run
terraform plan - Note that those properties are not part of the plan
Got the same behavior
Same problem seems to exist with conditions in opsgenie_integration_actions. The order field for integration actions and conditions for those actions are always saved as 0. An example
My code:
...
conditions {
order = 1
field = "tags"
operation = "matches"
expected_value = ".*prod.*"
}
conditions {
order = 2
field = "state"
operation = "matches"
expected_value = "open|test"
}
...
output of terraform show
...
conditions {
expected_value = "open|test"
field = "state"
not = false
operation = "matches"
order = 0
}
conditions {
expected_value = ".*prod.*"
field = "tags"
not = false
operation = "matches"
order = 0
}
...
Happy to make a separate issue for this if needed
Note: if anyone runs into this specific issue, there seems to be a deterministic order that conditions are saved in that ignores order. Since the order is not actually important, you can get around this by matching the deterministic order in your code. For example, changing my code to this fixes the issue of unwanted replacements.
conditions {
field = "state"
operation = "matches"
expected_value = "open|test"
}
conditions {
field = "tags"
operation = "matches"
expected_value = ".*prod.*"
}