jtopjian / terraform-provider-sensu

A Terraform provider for Sensu Go
21 stars 11 forks source link

Filter has default when block which makes the filter not behave correctly. #23

Closed qfliu closed 4 years ago

qfliu commented 4 years ago

For filters, the when block is optional. However, from our testing, if we do not specify when block, the resulting filter would have an empty when block that render the filter useless. The empty when block is not there if we use sensu-go UI to crate it.

Filter terraform code:

resource "sensu_filter" "filter_interval" {
  name = "filter_interval"
  action = "allow"
  expressions = [
    "event.check.interval == 10",
    "event.check.occurrences == 0 || event.check.occurrences %3 == 0",
  ]
}

resulting filter config from sensuctl command:

{
    "metadata": {
      "name": "filter_interval",
      "namespace": "test",
      "created_by": "admin"
    },
    "action": "allow",
    "expressions": [
      "event.check.interval == 10",
      "event.check.occurrences == 0 || event.check.occurrences % 3 == 0"
    ],
    "when": {
      "days": {}
    },
    "runtime_assets": null
  },

Filter config with same expression using sensu UI:

{
    "metadata": {
      "name": "manual_filter",
      "namespace": "test"
    },
    "action": "allow",
    "expressions": [
      "event.check.interval == 10",
      "event.check.occurrences == 0 || event.check.occurrences % 3 == 0"
    ],
    "runtime_assets": null
  }
jtopjian commented 4 years ago

@qfliu Thank you for reporting this. This should be fixed in #26. I'll update and close this issue when a new release has been made.

jtopjian commented 4 years ago

v0.8.0 has been released. I'm going to close this issue but let me know if you're still running into problems.