coralogix / terraform-provider-coralogix

Terraform provider for Coralogix
https://registry.terraform.io/providers/coralogix/coralogix
Apache License 2.0
9 stars 7 forks source link

Ability to manage notification groups through Terraform. #145

Open badcure opened 11 months ago

badcure commented 11 months ago

Description

There are many alerts that come out of the box. In our specific case for now, it would be the Okta alerts.

It would be nice to be able to through Terraform to programmatically attach notifications without the need to manage the alerts themselves, or create duplicate alerts.

New or Affected Resource(s)

Potential Terraform Configuration

data "coralogix_alerts" "okta_alerts" {
  name_search = "Okta -"
  labels = ["label1:value1", "lable2:value2"]
  status = "active/disabled"
  severity = "info"
}

resource "coralogix_alert_notification_group" "okta_notifications" {
  count = len(data.coralogix_alerts.okta_alerts.ids) 
  alert_id = data.coralogix_alerts.okta_alerts.ids[count.index]
  group_by_fields = []
  notification {
    integration_id              = coralogix_webhook.slack_staging.id
    retriggering_period_minutes = 10
  } 
}

References

None

Community Note

OrNovo commented 11 months ago

Hi @badcure, thanks for reaching out. We first need backend support to add this feature. We will prioritize it and update.

OrNovo commented 11 months ago

@badcure I have a question regarding the api you suggested though. Why do you want the linkage between the alert and the notification-group to be on the notification-group side? Wouldn't it be better to have something like that? -

resource "coralogix_alert_notification_group" "example_notifications" {
  group_by_fields = []
  notification {
    integration_id              = coralogix_webhook.slack_staging.id
    retriggering_period_minutes = 10
  } 
}

resource "coralogix_alert" "exaple_alert" {
  ...
  notifications_group = coralogix_alert_notification_group.example_notifications.id
 }
badcure commented 11 months ago

@OrNovo The issue with that direction is that it would work if we are creating the alert to begin with. The way I see it is there are many alerts that come from the extension packs. Let's say that I wanted to programmatically add additional notifications to them:

Currently: The way to do this is to duplicate those alerts into Terraform but with the new notification settings. Ideal state: We could retrieve the alerts and attach the notification policy that makes sense.

badcure commented 11 months ago

I updated the description with some additional ideas for the "data" resource. These are just ideas of course.

The reasoning is if I could say for a particular package:

Things like that.

OrNovo commented 11 months ago

@badcure I see. The downgrade is that you wouldn't be able to link a single notification-group for few alerts. Anyway, I'll forward your suggestion.

badcure commented 11 months ago

@OrNovo Ohh I see what you are saying, makes complete sense.

Maybe something similar to what AWS does with IAM roles and policy? Something like:

resource "coralogix_alert_notification_group_attachment" "okta_notifications" {
  alert_id = coralogix_alert.example.id
  notification_group_id = coralogix_alert_notification_group.example.id
}

That way it can satisfy both directions.