terraform-modules/observability/alerts.tf.off
2025-06-24 15:04:05 +02:00

49 lines
No EOL
1.5 KiB
Text

locals {
basic_auth = base64encode("${stackit_observability_credential.this.username}:${stackit_observability_credential.this.password}")
}
resource "local_sensitive_file" "alert_configs" {
content = templatefile("../../../../monitoring/alerts/dev/alertconfigs.json", {
msTeamWebhook = var.msTeamWebhook
})
filename = ".temp/alertconfigs.json"
}
resource "null_resource" "alert_configs" {
triggers = {
config = local_sensitive_file.alert_configs.content_sha1
url = var.observability_url
}
provisioner "local-exec" {
command = <<EOT
curl -X PUT "${var.observability_url}/${stackit_observability_instance.observability.instance_id}/alertconfigs" \
-d @${local_sensitive_file.alert_configs.filename} \
-H "Authorization: Basic ${local.basic_auth}" \
-H "Content-Type: application/json" \
--fail
EOT
}
}
resource "local_file" "alert_groups" {
content = templatefile("../../../../monitoring/alerts/dev/alertgroups.json", {
})
filename = ".temp/alertgroups.json"
}
resource "null_resource" "alert_groups" {
triggers = {
config = local_file.alert_groups.content_sha1
url = var.observability_url
}
provisioner "local-exec" {
command = <<EOT
curl -X PUT "${var.observability_url}/${stackit_observability_instance.observability.instance_id}/alertgroups" \
-d @${local_file.alert_groups.filename} \
-H "Authorization: Basic ${local.basic_auth}" \
-H "Content-Type: application/json" \
--fail
EOT
}
}