opsgenie / terraform-provider-opsgenie

Terraform OpsGenie provider
https://registry.terraform.io/providers/opsgenie/opsgenie/latest/docs
Mozilla Public License 2.0
103 stars 137 forks source link

Updating alert_description of an alert policy does not trigger a change #342

Open Wood12345678 opened 2 years ago

Wood12345678 commented 2 years ago

When trying to update the alert_description on an alert policy with a custom description after the policy has been created for the first time, upon trying to apply the change terraform recognises the change is needed but on applying the policy alert_description gets defaulted to {{description}} and the custom description does not get applied and terraform still sees the same change is needed when trying to apply for a third time.

Terraform Version

terraform -v
Terraform v1.3.3
on darwin_amd64
+ provider registry.terraform.io/opsgenie/opsgenie v0.6.15

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

I have replaced the team id with <TEAM ID> but this is where one of our team ids would go

resource "opsgenie_alert_policy" "test" {
  name                       = "Test Policy"
  team_id                    = opsgenie_team.opsgenie_team.id
  policy_description         = "This policy is a test policy"
  message                    = "{{message}}"
  alert_description          = "{{description}}"
  continue_policy            = true
  ignore_original_responders = false
  responders {
    type = "team"
    id   = "<TEAM ID>"
  }
  filter {
    type = "match-any-condition"
    conditions {
      field          = "priority"
      operation      = "equals"
      expected_value = "P1"
    }
  }
}

Debug Output

This is the output of trying to update the resource alert_description as you can see terraform picks up the change but once applied it does not get updated in OpsGenie:

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # opsgenie_alert_policy.test will be updated in-place
  ~ resource "opsgenie_alert_policy" "test" {
      ~ alert_description          = "{{description}}" -> "{{description}} Trying to update the alert description"
        id                         = "432e314d-b691-48a0-b757-3c13731ab6d6"
        name                       = "Test Policy"
        tags                       = []
        # (13 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

opsgenie_alert_policy.test: Modifying... [id=432e314d-b691-48a0-b757-3c13731ab6d6]
opsgenie_alert_policy.test: Modifications complete after 0s [id=432e314d-b691-48a0-b757-3c13731ab6d6]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

The image below is after the above run and you can see the change that terraform tries to make is not reflected in the OpsGenie Alert Policy

image

Expected Behavior

The expected behaviour that I would expect is to first apply a new OpsGenie alert policy, then when you go back and try to edit the alert_description or update the alert_description for it to update in place this resource and for the newly updated description to be used in the policy in Ops Genie

Actual Behavior

What actually happens is when trying to update the alert_policy description it shows the change in terraform but on apply does not update the alert description in OpsGenie

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create an alert policy
  2. Update the same alert policy with a new alert description