Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Idempotence in "instana_alerting_config" only with priorities/event_filter_event_types in alphabetical order #43

Closed
ppuschmann opened this issue Feb 25, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ppuschmann
Copy link
Contributor

ppuschmann commented Feb 25, 2020

There's a difference between writing

resource "instana_alerting_config" "my_resource" {
  alert_name               = "my-resource-alert"
  integration_ids          = ["${instana_alerting_channel_slack.alert_channel_in_slack.id}"]
  event_filter_query       = "entity.application.id:\"${instana_application_config.application_all.id}\""
  event_filter_event_types = ["critical", "incident", "warning"]
}

and

resource "instana_alerting_config" "my_ressource" {
  alert_name               = "my-ressource-alert"
  integration_ids          = ["${instana_alerting_channel_slack.alert_channel_in_slack.id}"]
  event_filter_query       = "entity.application.id:\"${instana_application_config.application_all.id}\""
  event_filter_event_types = ["incident", "critical", "warning"]
}

If written in the "human"-order of descending priorities / event_filter_event_types, you'd constantly get some changes on a terraform apply:

  # instana_alerting_config.alerting_eCom_general will be updated in-place
  ~ resource "instana_alerting_config" "my_resource" {
        alert_name               = "my-resource-alert"
      ~ event_filter_event_types = [
          - "critical",
            "incident",
          + "critical",
            "warning",
        ]
        event_filter_query       = "***************"
        event_filter_rule_ids    = []
        full_alert_name          = " my-resource-alert (TF)"
        id                       = "***************"
        integration_ids          = [
            "***************",
        ]
    }

If the priorities / event_filter_event_types are defined in alphabetical order, there will be no change.

This issue has only low priority.

@gessnerfl
Copy link
Owner

The root cause of this issue is the terraform data type. The data is stored in a list which is ordered. As we update the state is updated with the data coming from instana api, the order might change if instana is not returning the exact same order.
In contrast to this a set is an unordered list where items cannot be appear multiple times. This seems to be the better option in this case. I would expect a similar issue with the rule ids.

As an alternative the data type could be kept but the state is not getting updated with the data coming from instana. The only benefit of this approach would be to avoid a state migration. However I think changing the data type is the better approach.

@gessnerfl gessnerfl self-assigned this Feb 26, 2020
@gessnerfl gessnerfl added the bug Something isn't working label Feb 26, 2020
@gessnerfl
Copy link
Owner

gessnerfl commented Feb 28, 2020

The issue applies to the following resources:

For all of them, the items should be unique and Instana API might change the order. This exactly matches to the set behaviour of terraform (see also https://www.terraform.io/docs/extend/schemas/schema-types.html)

gessnerfl added a commit that referenced this issue Mar 2, 2020
gessnerfl added a commit that referenced this issue Mar 2, 2020
gessnerfl added a commit that referenced this issue Mar 2, 2020
gessnerfl added a commit that referenced this issue Mar 2, 2020
gessnerfl added a commit that referenced this issue Mar 2, 2020
#43 all mentioned fields are now migrated to sets to support unique elements and do not depend on the order
@gessnerfl
Copy link
Owner

gessnerfl commented Mar 2, 2020

@ppuschmann I provided a new version 0.8.2. This version should fix the issue for all the resources mentioned above including the alerting config. Can you please cross check

@ppuschmann
Copy link
Contributor Author

I need some time for this, but will come back to you.

@ppuschmann
Copy link
Contributor Author

I did check: It works!
Thank you very much for this improvement.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants