@@ -261,6 +261,33 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_importConfigNotifications(t *
261
261
})
262
262
}
263
263
264
+ func TestAccResourceMongoDBAtlasAlertConfiguration_DataDog (t * testing.T ) {
265
+ SkipTestExtCred (t ) // Will skip because requires external credentials aka api key
266
+ SkipTest (t ) // Will force skip if enabled
267
+ var (
268
+ resourceName = "mongodbatlas_alert_configuration.test"
269
+ projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
270
+ ddAPIKey = os .Getenv ("DD_API_KEY" )
271
+ ddRegion = "US"
272
+ alert = & matlas.AlertConfiguration {}
273
+ )
274
+
275
+ resource .Test (t , resource.TestCase {
276
+ PreCheck : func () { testAccPreCheck (t ) },
277
+ Providers : testAccProviders ,
278
+ CheckDestroy : testAccCheckMongoDBAtlasAlertConfigurationDestroy ,
279
+ Steps : []resource.TestStep {
280
+ {
281
+ Config : testAccMongoDBAtlasAlertConfigurationConfigWithDataDog (projectID , ddAPIKey , ddRegion , true ),
282
+ Check : resource .ComposeTestCheckFunc (
283
+ testAccCheckMongoDBAtlasAlertConfigurationExists (resourceName , alert ),
284
+ resource .TestCheckResourceAttrSet (resourceName , "project_id" ),
285
+ ),
286
+ },
287
+ },
288
+ })
289
+ }
290
+
264
291
func testAccCheckMongoDBAtlasAlertConfigurationExists (resourceName string , alert * matlas.AlertConfiguration ) resource.TestCheckFunc {
265
292
return func (s * terraform.State ) error {
266
293
conn := testAccProvider .Meta ().(* matlas.Client )
@@ -505,3 +532,49 @@ func testAccMongoDBAtlasAlertConfigurationConfigWithThresholdUpdated(projectID s
505
532
}
506
533
` , projectID , enabled , threshold )
507
534
}
535
+
536
+ func testAccMongoDBAtlasAlertConfigurationConfigWithDataDog (projectID , dataDogAPIKey , dataDogRegion string , enabled bool ) string {
537
+ return fmt .Sprintf (`
538
+ resource "mongodbatlas_third_party_integration" "atlas_datadog" {
539
+ project_id = "%[1]s"
540
+ type = "DATADOG"
541
+ api_key = "%[3]s"
542
+ region = "%[4]s"
543
+ }
544
+
545
+ resource "mongodbatlas_alert_configuration" "test" {
546
+ project_id = "%[1]s"
547
+ event_type = "REPLICATION_OPLOG_WINDOW_RUNNING_OUT"
548
+ enabled = %t
549
+
550
+ notification {
551
+ type_name = "GROUP"
552
+ interval_min = 5
553
+ delay_min = 0
554
+ sms_enabled = false
555
+ email_enabled = true
556
+ roles = ["GROUP_OWNER"]
557
+ }
558
+
559
+ notification {
560
+ type_name = "DATADOG"
561
+ datadog_api_key = mongodbatlas_third_party_integration.atlas_datadog.api_key
562
+ datadog_region = mongodbatlas_third_party_integration.atlas_datadog.region
563
+ interval_min = 5
564
+ delay_min = 0
565
+ }
566
+
567
+ matcher {
568
+ field_name = "HOSTNAME_AND_PORT"
569
+ operator = "EQUALS"
570
+ value = "SECONDARY"
571
+ }
572
+
573
+ threshold = {
574
+ operator = "LESS_THAN"
575
+ threshold = 72
576
+ units = "HOURS"
577
+ }
578
+ }
579
+ ` , projectID , enabled , dataDogAPIKey , dataDogRegion )
580
+ }
0 commit comments