variable "account" {
  type        = string
  description = "Snowflake account name"
}

variable "roles" {
  description = "List of objects containing role details"
  type = list(object({
    name                   = string
    granted_account_roles  = optional(list(string))
    granted_database_roles = optional(list(string))
    account_level_grants   = optional(set(string))
    comment                = optional(string, "Managed by terraform")
    owner                  = optional(string, "USERADMIN")
  }))

  validation {
    condition = alltrue([
      for role in var.roles : can(regex("[[:upper:]]", role.name))
    ])
    error_message = "Error: Role name must be uppercase."
  }
}

variable "revert_ownership_to" {
  type        = string
  default     = "USERADMIN"
  description = "Role to which will be reverted ownership from a custom ones during removal"
}
