diff --git a/mongodbatlas/fw_resource_mongodbatlas_alert_configuration.go b/mongodbatlas/fw_resource_mongodbatlas_alert_configuration.go index a35cbe892d..c0961cf253 100644 --- a/mongodbatlas/fw_resource_mongodbatlas_alert_configuration.go +++ b/mongodbatlas/fw_resource_mongodbatlas_alert_configuration.go @@ -291,6 +291,10 @@ func (r *AlertConfigurationRS) Schema(ctx context.Context, req resource.SchemaRe }, "interval_min": schema.Int64Attribute{ Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Int64{ + int64planmodifier.UseStateForUnknown(), + }, }, "mobile_number": schema.StringAttribute{ Optional: true, @@ -709,9 +713,6 @@ func newTFNotificationModelList(matlasSlice []matlas.Notification, currStateNoti if !currState.EmailAddress.IsNull() { newState.EmailAddress = conversion.StringNullIfEmpty(value.EmailAddress) } - if !currState.IntervalMin.IsNull() { - newState.IntervalMin = types.Int64Value(int64(value.IntervalMin)) - } if !currState.MobileNumber.IsNull() { newState.MobileNumber = conversion.StringNullIfEmpty(value.MobileNumber) } @@ -728,6 +729,7 @@ func newTFNotificationModelList(matlasSlice []matlas.Notification, currStateNoti newState.Username = conversion.StringNullIfEmpty(value.Username) } + newState.IntervalMin = types.Int64Value(int64(value.IntervalMin)) newState.DelayMin = types.Int64Value(int64(*value.DelayMin)) newState.EmailEnabled = types.BoolValue(value.EmailEnabled != nil && *value.EmailEnabled) newState.SMSEnabled = types.BoolValue(value.SMSEnabled != nil && *value.SMSEnabled) diff --git a/mongodbatlas/fw_resource_mongodbatlas_alert_configuration_test.go b/mongodbatlas/fw_resource_mongodbatlas_alert_configuration_test.go index 635c77f903..1f90f76a0f 100644 --- a/mongodbatlas/fw_resource_mongodbatlas_alert_configuration_test.go +++ b/mongodbatlas/fw_resource_mongodbatlas_alert_configuration_test.go @@ -317,6 +317,39 @@ func TestAccConfigRSAlertConfiguration_importConfigNotifications(t *testing.T) { }) } +// used for testing notification that does not define interval_min attribute +func TestAccConfigRSAlertConfiguration_importPagerDuty(t *testing.T) { + SkipTestExtCred(t) // Will skip because requires external credentials aka api key + var ( + resourceName = "mongodbatlas_alert_configuration.test" + projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") + serviceKey = os.Getenv("PAGER_DUTY_SERVICE_KEY") + alert = &matlas.AlertConfiguration{} + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheckBasic(t) }, + ProtoV6ProviderFactories: testAccProviderV6Factories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccMongoDBAtlasAlertConfigurationPagerDutyConfig(projectID, serviceKey, true), + Check: resource.ComposeTestCheckFunc( + testAccCheckMongoDBAtlasAlertConfigurationExists(resourceName, alert), + resource.TestCheckResourceAttrSet(resourceName, "project_id"), + ), + }, + { + ResourceName: resourceName, + ImportStateIdFunc: testAccCheckMongoDBAtlasAlertConfigurationImportStateIDFunc(resourceName), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"notification.0.service_key"}, // service key is not returned by api in import operation + }, + }, + }) +} + func TestAccConfigRSAlertConfiguration_DataDog(t *testing.T) { SkipTestExtCred(t) // Will skip because requires external credentials aka api key SkipTest(t) // Will force skip if enabled