appoptics / terraform-provider-appoptics

Apache License 2.0
4 stars 2 forks source link

Hard to compare changes in an alert condition #29

Open sandnabba opened 4 years ago

sandnabba commented 4 years ago

If something has changed in an alert condition, either in Terraform or if someone has altered the alert in the web interface, the output of a plan will look like this:

Terraform will perform the following actions:

  ~ module.staging-goalert-processingEvent.appoptics_alert.sqs_age_of_oldest_message
      condition.1259187324.detect_reset:     "false" => "false"
      condition.1259187324.duration:         "60" => "0"
      condition.1259187324.metric_name:      "AWS.SQS.ApproximateAgeOfOldestMessage" => ""
      condition.1259187324.summary_function: "average" => ""
      condition.1259187324.tag.#:            "2" => "0"
      condition.1259187324.tag.0.grouped:    "true" => "false"
      condition.1259187324.tag.0.name:       "queuename" => ""
      condition.1259187324.tag.0.values.#:   "1" => "0"
      condition.1259187324.tag.0.values.0:   "*tm-loggly-alerts-sqs*" => ""
      condition.1259187324.tag.1.grouped:    "true" => "false"
      condition.1259187324.tag.1.name:       "awsaccount" => ""
      condition.1259187324.tag.1.values.#:   "1" => "0"
      condition.1259187324.tag.1.values.0:   "tm-prod" => ""
      condition.1259187324.threshold:        "1" => "0"
      condition.1259187324.type:             "above" => ""
      condition.230406147.detect_reset:      "" => ""
      condition.230406147.duration:          "" => "60"
      condition.230406147.metric_name:       "" => "AWS.SQS.ApproximateAgeOfOldestMessage"
      condition.230406147.summary_function:  "" => "sum"
      condition.230406147.tag.#:             "0" => "2"
      condition.230406147.tag.0.grouped:     "" => "true"
      condition.230406147.tag.0.name:        "" => "queuename"
      condition.230406147.tag.0.values.#:    "0" => "1"
      condition.230406147.tag.0.values.0:    "" => "*tm-loggly-alerts-sqs*"
      condition.230406147.tag.1.grouped:     "" => "true"
      condition.230406147.tag.1.name:        "" => "awsaccount"
      condition.230406147.tag.1.values.#:    "0" => "1"
      condition.230406147.tag.1.values.0:    "" => "tm-prod"
      condition.230406147.threshold:         "" => "1"
      condition.230406147.type:              "" => "above"

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

By just having a quick look at this output, it's very hard to tell which settings that have changed. (It's the summary_function). The problem here is that the condition have got a new id, which is causing this behavior.

The strange thing however is that if I then change the summary_function in the GUI, Terraform will detect that change:

emil@DvorakWork: ~/git/ops/sre-metrocard/estate/threatmonitor/terraform-templates/appoptics $> terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

appoptics_alert.sqs_age_of_oldest_message: Refreshing state... (ID: 61327598)
appoptics_alert.sqs_incorrect_format: Refreshing state... (ID: 61161139)

------------------------------------------------------------------------

No changes. Infrastructure is up-to-date.

So I guess it would be possible to get a nicer output from a plan.

Expected result

Terraform will perform the following actions:

  ~ module.staging-goalert-processingEvent.appoptics_alert.sqs_age_of_oldest_message
      condition.1259187324.summary_function: "average" => "sum"

Plan: 0 to add, 1 to change, 0 to destroy.
solarchad commented 4 years ago

Thanks for the details. Let me follow up with the AO team to see if conditions can be modified in place or if doing so creates a whole new condition object within the alert.

solarchad commented 4 years ago

@petercable do you know off-hand if we change an attribute in an alert condition, if we have to create a whole new condition or are we able to modify the existing condition? In other words, will changing a condition create a new condition ID?