@@ -190,6 +190,36 @@ func TestAccSumologicMonitorsLibraryMonitor_basic(t *testing.T) {
190190 },
191191 })
192192}
193+
194+ func TestAccSumologicMonitorsLibraryMonitor_create_monitor_with_linked_playbook (t * testing.T ) {
195+ var monitorsLibraryMonitor MonitorsLibraryMonitor
196+ testNameSuffix := acctest .RandString (16 )
197+
198+ testName := "terraform_test_monitor_" + testNameSuffix
199+
200+ // NOTE: This playbook ID refers to a static playbook `[Do Not Delete] Playbook Used in Terraform Tests`. Replace with a valid playbook ID in your environment.
201+ playbook_id := "6877cae1fb301f15fca89f67"
202+
203+ resource .Test (t , resource.TestCase {
204+ PreCheck : func () { testAccPreCheck (t ) },
205+ Providers : testAccProviders ,
206+ CheckDestroy : testAccCheckMonitorsLibraryMonitorDestroy (),
207+ Steps : []resource.TestStep {
208+ {
209+ Config : testAccSumologicMonitorWithLinkedPlaybook (testName , playbook_id ),
210+ Check : resource .ComposeTestCheckFunc (
211+ testAccCheckMonitorsLibraryMonitorExists ("sumologic_monitor.test" , & monitorsLibraryMonitor ),
212+ resource .TestCheckResourceAttr ("sumologic_monitor.test" , "automated_playbook_ids.0" , playbook_id )),
213+ },
214+ {
215+ ResourceName : "sumologic_monitor.test" ,
216+ ImportState : true ,
217+ ImportStateVerify : false ,
218+ },
219+ },
220+ })
221+ }
222+
193223func TestAccSumologicMonitorsLibraryMonitor_create (t * testing.T ) {
194224 var monitorsLibraryMonitor MonitorsLibraryMonitor
195225 testNameSuffix := acctest .RandString (16 )
@@ -796,6 +826,56 @@ func testAccCheckMonitorsLibraryMonitorAttributes(name string) resource.TestChec
796826 }
797827}
798828
829+ func testAccSumologicMonitorWithLinkedPlaybook (testName , playbookId string ) string {
830+ return fmt .Sprintf (`
831+ resource "sumologic_monitor" "test" {
832+ name = "terraform_test_monitor_%s"
833+ description = "terraform_test_monitor_description"
834+ type = "MonitorsLibraryMonitor"
835+ is_disabled = false
836+ content_type = "Monitor"
837+ monitor_type = "Logs"
838+ evaluation_delay = "60m"
839+ time_zone = "America/New_York"
840+ queries {
841+ row_id = "A"
842+ query = "_sourceCategory=monitor-manager error"
843+ }
844+ triggers {
845+ threshold_type = "GreaterThan"
846+ threshold = 40.0
847+ time_range = "-60m"
848+ occurrence_type = "ResultCount"
849+ trigger_source = "AllResults"
850+ trigger_type = "Critical"
851+ detection_method = "StaticCondition"
852+ }
853+ triggers {
854+ threshold_type = "LessThanOrEqual"
855+ threshold = 40.0
856+ time_range = "-60m"
857+ occurrence_type = "ResultCount"
858+ trigger_source = "AllResults"
859+ trigger_type = "ResolvedCritical"
860+ detection_method = "StaticCondition"
861+ resolution_window = "5m"
862+ }
863+ notifications {
864+ notification {
865+ connection_type = "Email"
866+ recipients = ["[email protected] "] 867+ subject = "test tf monitor"
868+ time_zone = "PST"
869+ message_body = "test"
870+ }
871+ run_for_trigger_types = ["Critical", "ResolvedCritical"]
872+ }
873+ playbook = "This is a test playbook"
874+ automated_playbook_ids = ["%s"]
875+ alert_name = "Alert from {{Name}}"
876+ }` , testName , playbookId )
877+ }
878+
799879func testAccSumologicMonitorsLibraryMonitor (testName string ) string {
800880 return fmt .Sprintf (`
801881resource "sumologic_monitor" "test" {
0 commit comments