0

I want to create GCP monitoring alert policies through Terraform. I have downloaded alert policies as json files. I can create alert policy in Terraform using

    resource "google_monitoring_alert_policy" "alert_policy" {
      project = var.project_id
      display_name = "alert_name"
      combiner = "OR"
      conditions {
        display_name = "alert_name"
        condition_threshold {
          "filter": "resource.type = \"gce_instance\" AND metric.type = \"compute.googleapis.com/instance/cpu/utilization\"",
.........
    }

But instead of providing alert policy configuration in the Terraform script like above, I want to read it from alert policy JSON files.
Also, I have multiple alerts in different JSON files in a directory.
And multiple conditions in each alert policy.
How to loop through them in Terraform and create alert policies using each JSON file? Thanks.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.