terraform {
  required_providers {
    zitadel = {
      source  = "zitadel/zitadel"
      version = "2.0.2"
    }
  }
}

resource "zitadel_project_role" "default" {
  count = length(var.roles)
  depends_on = [var.wait_on]

  org_id       = var.org_id
  project_id   = var.project_id
  role_key     = var.roles[count.index]
  display_name = var.roles[count.index]
  group        = var.group
}

output "installed" {
  value = true
  depends_on = [zitadel_project_role.default]
}

output "role_ids" {
  value = toset([
    for role in zitadel_project_role.default : role.id
  ])
}

output "roles" {
  value = var.roles
}
