splunk / terraform-provider-splunk

Terraform Provider for Splunk
Mozilla Public License 2.0
105 stars 78 forks source link

Empty string values are not being set #35

Open zscholl opened 4 years ago

zscholl commented 4 years ago

It seems that if you want to clear out a value using an empty string that the provider is not updating Splunk.

Here's an example of a failing test when using an empty string: https://github.com/splunk/terraform-provider-splunk/pull/34

resource "splunk_saved_searches" "test" {
    name = "[Test New Alert]"
    search = "index=main"
    actions = "email"
    action_email_include_search = 1
    action_email_include_trigger = 1
    action_email_format = "table"
    action_email_max_time = "5m"
    action_email_max_results = 100
    action_email_send_csv = 1
    action_email_send_results = false
    action_email_subject = ""
    action_email_to = "splunk@splunk.com"
    action_email_track_alert = true
    dispatch_earliest_time = "rt-15m"
    dispatch_latest_time = "rt-0m"
    dispatch_index_earliest = "-20m"
    dispatch_index_latest = "-5m"
    cron_schedule = "*/15 * * * *"
    acl {
      owner = "admin"
      sharing = "app"
      app = "launcher"
    }
}
anushjay commented 3 years ago

@zscholl I looked into this and according to Terraform, if an argument is set to null or empty, or being omitted Terraform will use the argument's default value. In this case, the argument is optional which is why I believe terraform is not capturing the change of state or value of the argument. (https://www.terraform.io/docs/configuration/expressions/types.html) We can either have a default value for argument or If you want to try setting the action_email_subject to an empty space that should work as well. Let me know your thoughts.