SumoLogic/terraform-provider-sumologic

log-search: cron_expression is populated and so subsequent plans show drift if not provided

eambrosyupgrade opened this issue · 0 comments

Documentation for log-search's schedule shows that cron_expression is an optional field; and that schedule type takes precedence if provided. https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/resources/log_search#cron_expression

However if I create a scheduled search with a type and don't provide a log expression, subsequent plans show a cron expression filled and so I have perpetual drift.

My resource:

resource "sumologic_log_search" "log_search" {
    description         = "Ingest Outlier - Managed by Terraform"
    id                  = (known after apply)
    name                = "Ingest Outlier"
    parent_id           = "000000000470D11A"
    parsing_mode        = "Manual"
    query_string        = <<-EOT
        my_query
    EOT
    run_by_receipt_time = false

    schedule {
        mute_error_emails = true
        schedule_type     = "8Hours"
        time_zone         = "America/New_York"

        notification {
            webhook_search_notification {
                itemize_alerts = false
                payload        = jsonencode(
                    {
                        blocks = [
                            {
                                accessory = {
                                    action_id = "overflow-action"
                                    options   = [
                                        {
                                            text  = {
                                                emoji = true
                                                text  = "{{Results.event_time}}"
                                                type  = "plain_text"
                                            }
                                            value = "value-0"
                                        },
                                        {
                                            text  = {
                                                emoji = true
                                                text  = "Sumo Link"
                                                type  = "plain_text"
                                            }
                                            url   = "{{QueryURL}}"
                                            value = "value-1"
                                        },
                                    ]
                                    type      = "overflow"
                                }
                                text      = {
                                    text = "Ingest exceed 1 Standard Deviation from the mean :`{{Results.message}}`"
                                    type = "mrkdwn"
                                }
                                type      = "section"
                            },
                        ]
                    }
                )
                webhook_id     = "MYID"
            }
        }

        parseable_time_range {
            begin_bounded_time_range {
                from {
                    relative_time_range {
                        relative_time = "-7d"
                    }
                }
            }
        }

        threshold {
            count          = 0
            operator       = "gt"
            threshold_type = "message"
        }
    }

    time_range {
        begin_bounded_time_range {
            from {
                relative_time_range {
                    relative_time = "-7d"
                }
            }
        }
    }
}

Once applied subsequent plans show:

~ resource "sumologic_log_search" "log_search" {
        id                  = "ID"
        name                = "Ingest Outlier"
        # (5 unchanged attributes hidden)

    ~ schedule {
        - cron_expression   = "0 0 0/8 * * ? *" -> null
            # (3 unchanged attributes hidden)

            # (3 unchanged blocks hidden)
        }

        # (1 unchanged block hidden)
    }

Expected Behavior

That since schedule_type is provided and is not custom, I should not need to have a cron_expression and its dif is not returned to me. Else this input should be labeled as required.