locals {
    victorops_team = var.environment == "test" ? "test" : "engineering"
}

resource "sensu_handler" "handler_keepalive" {
  name      = "keepalive"
  type      = "set"
  namespace = "default"
  handlers  = [ "victorops", ]
}

resource "sensu_handler" "handler_victorops" {
  name           = "victorops"
  type           = "pipe"
  namespace      = "default"
  handlers       = [ "victorops", ]
  filters        = [ "is_incident", "not_silenced", "handler-delay", ]
  runtime_assets = [ "sensu-plugins-victorops", "sensu-ruby-runtime", ]
  command        = "handler-victorops.rb --map_go_event_into_ruby -a https://alert.victorops.com/integrations/generic/20131114/alert/864a1b38-4243-4137-8baa-b587ba5f300b/ -r ${local.victorops_team}"
}

resource "sensu_handler" "handler_logfile" {
  name           = "logfile"
  type           = "pipe"
  namespace      = "default"
  handlers       = [ ]
  filters        = [ ]
  runtime_assets = [ "sensu-ruby-runtime", ]
  command        = "/usr/local/bin/stdin_to_log.py"
}
