jtopjian / terraform-provider-sensu

A Terraform provider for Sensu Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

qfliu opened this issue · comments

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
  }

@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.

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