Skip to content

Perpetual drift using opsgenie_integration_action.cloudwatch resource #464

@fhperuchi

Description

@fhperuchi

I am having a perpetual Terraform drift when planning (terraform plan) this resource below:

resource "opsgenie_integration_action" "cloudwatch" {
  integration_id = opsgenie_api_integration.cloudwatch.id

  create {
    order       = 1
    name        = "Create alert - P1"
    alias       = local.alias
    tags        = ["env:${var.environment}"]
    message     = local.message
    description = local.message
    source      = local.source
    entity      = local.entity
    priority    = "P1"
    user        = local.user
    filter {
      type = "match-all-conditions"
      conditions {
        order          = 1
        field          = "NewStateValue"
        operation      = "equals"
        expected_value = "ALARM"
      }
      conditions {
        order          = 2
        field          = local.alarm_description_field
        operation      = "contains"
        expected_value = "@P1"
      }
    }
  }

  create {
    order       = 2
    name        = "Create alert - P2"
    alias       = local.alias
    tags        = ["env:${var.environment}"]
    message     = local.message
    description = local.message
    source      = local.source
    entity      = local.entity
    priority    = "P2"
    user        = local.user
    filter {
      type = "match-all-conditions"
      conditions {
        order          = 1
        field          = "NewStateValue"
        operation      = "equals"
        expected_value = "ALARM"
      }
      conditions {
        order          = 2
        field          = local.alarm_description_field
        operation      = "contains"
        expected_value = "@P2"
      }
    }
  }

  create {
    order       = 3
    name        = "Create alert - P3"
    alias       = local.alias
    tags        = ["env:${var.environment}"]
    message     = local.message
    description = local.message
    source      = local.source
    entity      = local.entity
    priority    = "P3"
    user        = local.user
    filter {
      type = "match-all-conditions"
      conditions {
        order          = 1
        field          = "NewStateValue"
        operation      = "equals"
        expected_value = "ALARM"
      }
      conditions {
        order          = 2
        field          = local.alarm_description_field
        operation      = "contains"
        expected_value = "@P3"
      }
    }
  }

  create {
    order       = 4
    name        = "Create alert - P4"
    alias       = local.alias
    tags        = ["env:${var.environment}"]
    message     = local.message
    description = local.message
    source      = local.source
    entity      = local.entity
    priority    = "P4"
    user        = local.user
    filter {
      type = "match-all-conditions"
      conditions {
        order          = 1
        field          = "NewStateValue"
        operation      = "equals"
        expected_value = "ALARM"
      }
      conditions {
        order          = 2
        field          = local.alarm_description_field
        operation      = "contains"
        expected_value = "@P4"
      }
    }
  }

  create {
    order       = 5
    name        = "Create alert - P5"
    alias       = local.alias
    tags        = ["env:${var.environment}"]
    message     = local.message
    description = local.message
    source      = local.source
    entity      = local.entity
    priority    = "P5"
    user        = local.user
    filter {
      type = "match-all-conditions"
      conditions {
        order          = 1
        field          = "NewStateValue"
        operation      = "equals"
        expected_value = "ALARM"
      }
      conditions {
        order          = 2
        field          = local.alarm_description_field
        operation      = "contains"
        expected_value = "@P5"
      }
    }
  }

  create {
    name        = "Create alert (does not contain @)"
    alias       = local.alias
    tags        = ["env:${var.environment}", "misconfigured-alert"]
    message     = local.message_full
    description = local.message_full
    source      = local.source
    entity      = local.entity
    priority    = "P3"
    user        = local.user
    filter {
      type = "match-all-conditions"
      conditions {
        order          = 1
        field          = "NewStateValue"
        operation      = "equals"
        expected_value = "ALARM"
      }
      conditions {
        order          = 2
        field          = local.alarm_description_field
        operation      = "contains"
        expected_value = "@P"
        not            = true
      }
    }
  }

  close {
    name = "Close alert"
    filter {
      type = "match-all-conditions"
      conditions {
        field          = "NewStateValue"
        operation      = "equals"
        expected_value = "OK"
      }
    }
    alias = local.alias
    user  = local.user
  }
}

Drift:

opsgenie_integration_action.cloudwatch: Refreshing state... [id=fc487fbf-089d-4a4c-af25-5484982154bf]

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_integration_action.cloudwatch will be updated in-place
  ~ resource "opsgenie_integration_action" "cloudwatch" {
        id             = "fc487fbf-089d-4a4c-af25-5484982154bf"
        # (1 unchanged attribute hidden)

      ~ create {
          ~ ignore_responders_from_payload       = true -> false
            name                                 = "Create alert - P1"
            tags                                 = [
                "env:shared-dev",
            ]
            # (17 unchanged attributes hidden)

          ~ filter {
                # (1 unchanged attribute hidden)

              - conditions {
                  - expected_value = "@P1" -> null
                  - field          = "AlarmDescription" -> null
                  - not            = false -> null
                  - operation      = "contains" -> null
                  - order          = 0 -> null
                }
              - conditions {
                  - expected_value = "ALARM" -> null
                  - field          = "NewStateValue" -> null
                  - not            = false -> null
                  - operation      = "equals" -> null
                  - order          = 0 -> null
                }
              + conditions {
                  + expected_value = "@P1"
                  + field          = "AlarmDescription"
                  + not            = false
                  + operation      = "contains"
                  + order          = 2
                }
              + conditions {
                  + expected_value = "ALARM"
                  + field          = "NewStateValue"
                  + not            = false
                  + operation      = "equals"
                  + order          = 1
                }
            }

          - responders {
              - id   = "64c05ae8-8f5d-4ecb-8947-d9e99a46d2bb" -> null
              - type = "team" -> null
            }
        }
      ~ create {
          ~ description                          = "{{ AlarmDescription }}" -> "{{ AlarmDescription.substringBefore(\"@\") }}"
          ~ ignore_responders_from_payload       = true -> false
          ~ message                              = "{{ AlarmDescription }}" -> "{{ AlarmDescription.substringBefore(\"@\") }}"
          ~ name                                 = "Create alert (does not contain @)" -> "Create alert - P2"
          ~ priority                             = "P3" -> "P2"
          ~ tags                                 = [
                "env:shared-dev",
              - "misconfigured-alert",
            ]
            # (14 unchanged attributes hidden)

          ~ filter {
                # (1 unchanged attribute hidden)

              - conditions {
                  - expected_value = "@P" -> null
                  - field          = "AlarmDescription" -> null
                  - not            = true -> null
                  - operation      = "contains" -> null
                  - order          = 0 -> null
                }
              - conditions {
                  - expected_value = "ALARM" -> null
                  - field          = "NewStateValue" -> null
                  - not            = false -> null
                  - operation      = "equals" -> null
                  - order          = 0 -> null
                }
              + conditions {
                  + expected_value = "@P2"
                  + field          = "AlarmDescription"
                  + not            = false
                  + operation      = "contains"
                  + order          = 2
                }
              + conditions {
                  + expected_value = "ALARM"
                  + field          = "NewStateValue"
                  + not            = false
                  + operation      = "equals"
                  + order          = 1
                }
            }

          - responders {
              - id   = "64c05ae8-8f5d-4ecb-8947-d9e99a46d2bb" -> null
              - type = "team" -> null
            }
        }
      ~ create {
          ~ ignore_responders_from_payload       = true -> false
          ~ name                                 = "Create alert - P2" -> "Create alert - P3"
          ~ priority                             = "P2" -> "P3"
            tags                                 = [
                "env:shared-dev",
            ]
            # (16 unchanged attributes hidden)

          ~ filter {
                # (1 unchanged attribute hidden)

              - conditions {
                  - expected_value = "@P2" -> null
                  - field          = "AlarmDescription" -> null
                  - not            = false -> null
                  - operation      = "contains" -> null
                  - order          = 0 -> null
                }
              - conditions {
                  - expected_value = "ALARM" -> null
                  - field          = "NewStateValue" -> null
                  - not            = false -> null
                  - operation      = "equals" -> null
                  - order          = 0 -> null
                }
              + conditions {
                  + expected_value = "@P3"
                  + field          = "AlarmDescription"
                  + not            = false
                  + operation      = "contains"
                  + order          = 2
                }
              + conditions {
                  + expected_value = "ALARM"
                  + field          = "NewStateValue"
                  + not            = false
                  + operation      = "equals"
                  + order          = 1
                }
            }

          - responders {
              - id   = "64c05ae8-8f5d-4ecb-8947-d9e99a46d2bb" -> null
              - type = "team" -> null
            }
        }
      ~ create {
          ~ ignore_responders_from_payload       = true -> false
          ~ name                                 = "Create alert - P3" -> "Create alert - P4"
          ~ priority                             = "P3" -> "P4"
            tags                                 = [
                "env:shared-dev",
            ]
            # (16 unchanged attributes hidden)

          ~ filter {
                # (1 unchanged attribute hidden)

              - conditions {
                  - expected_value = "@P3" -> null
                  - field          = "AlarmDescription" -> null
                  - not            = false -> null
                  - operation      = "contains" -> null
                  - order          = 0 -> null
                }
              - conditions {
                  - expected_value = "ALARM" -> null
                  - field          = "NewStateValue" -> null
                  - not            = false -> null
                  - operation      = "equals" -> null
                  - order          = 0 -> null
                }
              + conditions {
                  + expected_value = "@P4"
                  + field          = "AlarmDescription"
                  + not            = false
                  + operation      = "contains"
                  + order          = 2
                }
              + conditions {
                  + expected_value = "ALARM"
                  + field          = "NewStateValue"
                  + not            = false
                  + operation      = "equals"
                  + order          = 1
                }
            }

          - responders {
              - id   = "64c05ae8-8f5d-4ecb-8947-d9e99a46d2bb" -> null
              - type = "team" -> null
            }
        }
      ~ create {
          ~ ignore_responders_from_payload       = true -> false
          ~ name                                 = "Create alert - P4" -> "Create alert - P5"
          ~ priority                             = "P4" -> "P5"
            tags                                 = [
                "env:shared-dev",
            ]
            # (16 unchanged attributes hidden)

          ~ filter {
                # (1 unchanged attribute hidden)

              - conditions {
                  - expected_value = "@P4" -> null
                  - field          = "AlarmDescription" -> null
                  - not            = false -> null
                  - operation      = "contains" -> null
                  - order          = 0 -> null
                }
              - conditions {
                  - expected_value = "ALARM" -> null
                  - field          = "NewStateValue" -> null
                  - not            = false -> null
                  - operation      = "equals" -> null
                  - order          = 0 -> null
                }
              + conditions {
                  + expected_value = "@P5"
                  + field          = "AlarmDescription"
                  + not            = false
                  + operation      = "contains"
                  + order          = 2
                }
              + conditions {
                  + expected_value = "ALARM"
                  + field          = "NewStateValue"
                  + not            = false
                  + operation      = "equals"
                  + order          = 1
                }
            }

          - responders {
              - id   = "64c05ae8-8f5d-4ecb-8947-d9e99a46d2bb" -> null
              - type = "team" -> null
            }
        }
      ~ create {
          ~ description                          = "{{ AlarmDescription.substringBefore(\"@\") }}" -> "{{ AlarmDescription }}"
          ~ ignore_responders_from_payload       = true -> false
          ~ message                              = "{{ AlarmDescription.substringBefore(\"@\") }}" -> "{{ AlarmDescription }}"
          ~ name                                 = "Create alert - P5" -> "Create alert (does not contain @)"
          ~ order                                = 6 -> 1
          ~ priority                             = "P5" -> "P3"
          ~ tags                                 = [
                "env:shared-dev",
              + "misconfigured-alert",
            ]
            # (13 unchanged attributes hidden)

          ~ filter {
                # (1 unchanged attribute hidden)

              - conditions {
                  - expected_value = "@P5" -> null
                  - field          = "AlarmDescription" -> null
                  - not            = false -> null
                  - operation      = "contains" -> null
                  - order          = 0 -> null
                }
              - conditions {
                  - expected_value = "ALARM" -> null
                  - field          = "NewStateValue" -> null
                  - not            = false -> null
                  - operation      = "equals" -> null
                  - order          = 0 -> null
                }
              + conditions {
                  + expected_value = "@P"
                  + field          = "AlarmDescription"
                  + not            = true
                  + operation      = "contains"
                  + order          = 2
                }
              + conditions {
                  + expected_value = "ALARM"
                  + field          = "NewStateValue"
                  + not            = false
                  + operation      = "equals"
                  + order          = 1
                }
            }

          - responders {
              - id   = "64c05ae8-8f5d-4ecb-8947-d9e99a46d2bb" -> null
              - type = "team" -> null
            }
        }

        # (1 unchanged block hidden)
    }

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

Is there a way to fix it without adding ignore_changes like this?

  lifecycle {
    ignore_changes = [create]
  }

Any help is welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions