Skip to content
11 changes: 11 additions & 0 deletions .changelog/3795.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```release-note:enhancement
data-source/mongodbatlas_alert_configuration: Adds `severity_override` attribute
```

```release-note:enhancement
data-source/mongodbatlas_alert_configurations: Adds `severity_override` attribute
```

```release-note:enhancement
resource/mongodbatlas_alert_configuration: Adds `severity_override` attribute
```
1 change: 1 addition & 0 deletions contributing/testing-best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- `Basic import tests` are done as the last step in the `basic acceptance tests`, not as a different test, e.g. [basicTestCase](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/66c44e62c9afe04ffe8be0dbccaec682bab830e6/internal/service/searchindex/resource_search_index_test.go#L211). Exceptions apply for more specific import tests, e.g. testing with incorrect IDs. [Import tests](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/import#resource-acceptance-testing-implementation) verify that the [Terraform Import](https://developer.hashicorp.com/terraform/cli/import) functionality is working fine.
- Data sources are tested in the same tests as the resources, e.g. [commonChecks](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/66c44e62c9afe04ffe8be0dbccaec682bab830e6/internal/service/searchindex/resource_search_index_test.go#L262-L263).
- Helper functions such as `resource.TestCheckTypeSetElemNestedAttrs` or `resource.TestCheckTypeSetElemAttr` can be used to check resource and data source attributes more easily, e.g. [resource_serverless_instance_test.go](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/66c44e62c9afe04ffe8be0dbccaec682bab830e6/internal/service/serverlessinstance/resource_serverless_instance_test.go#L61).
- Note: before running the acceptance tests, make sure you set the environment variable `TF_ACC=1`.

### Cloud Gov tests

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/alert_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ In addition to all arguments above, the following attributes are exported:
* `metric_threshold_config` - The threshold that causes an alert to be triggered. Required if `event_type_name` : `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`. See [metric threshold config](#metric-threshold-config).
* `threshold_config` - Threshold that triggers an alert. Required if `event_type_name` is any value other than `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`. See [threshold config](#threshold-config).
* `notifications` - List of notifications to send when an alert condition is detected. See [notifications](#notifications).
* `severity_override` - Severity of the event.

-> ***IMPORTANT:*** Event Type has many possible values. Details for both conditional and metric based alerts can be found by selecting the tabs on the [alert config page](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createalertconfiguration) and checking the latest eventTypeName options.

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/alert_configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ In addition to all arguments above, the following attributes are exported:
* `metric_threshold_config` - The threshold that causes an alert to be triggered. Required if `event_type_name` : `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`. See [metric threshold config](#metric-threshold-config).
* `threshold_config` - Threshold that triggers an alert. Required if `event_type_name` is any value other than `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`. See [threshold config](#threshold-config).
* `notifications` - List of notifications to send when an alert condition is detected. See [notifications](#notifications).
* `severity_override` - Severity of the event.
* `output` - Requested output string format for the alert configuration

-> ***IMPORTANT:*** Event Type has many possible values. Details for both conditional and metric based alerts can be found by selecting the tabs on the [alert config page](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createalertconfiguration) and checking the latest eventTypeName options.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/alert_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ resource "mongodbatlas_alert_configuration" "test" {


-> **NOTE:** If `event_type` is set to `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`, the `metric_threshold_config` field must also be configured.
* `severity_override` - (Optional) Severity of the event. For the list of accepted values please read the [Create One Alert Configuration in One Project](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-creategroupalertconfig) API documentation

### Matchers
Rules to apply when matching an object against this alert configuration. Only entities that match all these rules are checked for an alert condition. You can filter using the matchers array only when the eventTypeName specifies an event for a host, replica set, or sharded cluster.
Expand Down
8 changes: 8 additions & 0 deletions internal/service/alertconfiguration/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type TFAlertConfigurationDSModel struct {
EventType types.String `tfsdk:"event_type"`
Created types.String `tfsdk:"created"`
Updated types.String `tfsdk:"updated"`
SeverityOverride types.String `tfsdk:"severity_override"`
Matcher []TfMatcherModel `tfsdk:"matcher"`
MetricThresholdConfig []TfMetricThresholdConfigModel `tfsdk:"metric_threshold_config"`
ThresholdConfig []TfThresholdConfigModel `tfsdk:"threshold_config"`
Expand Down Expand Up @@ -242,6 +243,9 @@ var alertConfigDSSchemaAttributes = map[string]schema.Attribute{
},
},
},
"severity_override": schema.StringAttribute{
Computed: true,
},
}

func (d *alertConfigurationDS) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
Expand Down Expand Up @@ -339,6 +343,10 @@ func outputAlertConfigurationResourceHcl(label string, alert *admin.GroupAlertsC
appendBlockWithCtyValues(resource, "notification", []string{}, convertNotificationToCtyValues(&notifications[i]))
}

if alert.SeverityOverride != nil {
resource.SetAttributeValue("severity_override", cty.StringVal(*alert.SeverityOverride))
}

return string(f.Bytes())
}

Expand Down
2 changes: 2 additions & 0 deletions internal/service/alertconfiguration/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func NewTFAlertConfigurationModel(apiRespConfig *admin.GroupAlertsConfig, currSt
ThresholdConfig: NewTFThresholdConfigModel(apiRespConfig.Threshold, currState.ThresholdConfig),
Notification: NewTFNotificationModelList(apiRespConfig.GetNotifications(), currState.Notification),
Matcher: NewTFMatcherModelList(apiRespConfig.GetMatchers(), currState.Matcher),
SeverityOverride: types.StringPointerValue(apiRespConfig.SeverityOverride),
}
}

Expand Down Expand Up @@ -298,6 +299,7 @@ func NewTfAlertConfigurationDSModel(apiRespConfig *admin.GroupAlertsConfig, proj
ThresholdConfig: NewTFThresholdConfigModel(apiRespConfig.Threshold, []TfThresholdConfigModel{}),
Notification: NewTFNotificationModelList(apiRespConfig.GetNotifications(), []TfNotificationModel{}),
Matcher: NewTFMatcherModelList(apiRespConfig.GetMatchers(), []TfMatcherModel{}),
SeverityOverride: types.StringPointerValue(apiRespConfig.SeverityOverride),
}
}

Expand Down
Loading