Opsgenie create alert

From wikieduonline
Revision as of 09:59, 1 October 2024 by Welcome (talk | contribs) (→‎Related)
Jump to navigation Jump to search

Install the Opsgenie Provider in Terraform

terraform {
  required_providers {
    opsgenie = {
      source = "opsgenie/opsgenie"
      version = "0.5.0"  # or the latest version
    }
  }
} 

provider "opsgenie" {
  api_key = var.opsgenie_api_key  # Replace with your API key or use a secret variable
}


Create alert

resource "opsgenie_alert" "terraform_alert" {
  message     = "Terraform Alert: Plan Execution Failure"
  alias       = "terraform-plan-failure"
  description = "Terraform plan execution failed for the dev environment."
  teams       = [opsgenie_team.example_team.name]  # Specify your team
  priority    = "P1"
  tags = [
    "terraform",
    "failure"
  ]

  details = {
    region   = "us-east-1"
    severity = "high"
  }
}


Related

See also

Advertising: