variable "wait_on" {
  type        = any
  description = "Resources to wait on"
  default     = true
}

variable "server_ip" {
  type = string
}

variable "ssh_private_key_path" {
  type = string
}

resource "random_password" "username" {
  length  = 32 
  special = false
}

resource "random_password" "password" {
  length  = 32 
  special = false
}

module "redis" {
  source = "../quadlet-app"
  wait_on = var.wait_on

  server_ip            = var.server_ip
  ssh_private_key_path = var.ssh_private_key_path

  app_name = "documentdb"
  image    = "ghcr.io/documentdb/documentdb/documentdb-local:latest"
  ports    = ["27017:27017"]
  volumes  = ["/opt/storage/data/documentdb:/data:Z"]
  environment = {
    USERNAME = random_password.username.result
    PASSWORD = random_password.password.result
  }
}

output "app_urls" {
  value = module.redis.app_urls
}

output "installed" {
  value = true
  depends_on = [module.redis.installed]
}

output "username" {
  value = random_password.username.result
  sensitive = true
}

output "password" {
  value = random_password.password.result
  sensitive = true
}