resource "nomad_job" "ntfy" {
  jobspec = file("ntfy.nomad.hcl")
}

resource "nomad_variable" "ntfy" {
  path = "nomad/jobs/ntfy"
  items = {
    database_pw = data.sops_file.secrets.data["ntfy.database_pw"]
  }
}

resource "postgresql_role" "ntfy" {
  name     = "ntfy"
  password = data.sops_file.secrets.data["ntfy.database_pw"]
  login    = true
}

resource "postgresql_database" "ntfy" {
  name  = "ntfy"
  owner = postgresql_role.ntfy.name
}
