module "cluster-app-365zon-bootstrap" {
  source  = "../../../modules/cluster/bootstrap"
  wait_on = module.vault.installed

  cluster = "app-365zon"

  vault_server     = module.vault.vault_uri
  vault_root_token = module.vault.vault_root_token
  minio_access_key = module.minio.minio_access_key
  minio_secret_key = module.minio.minio_secret_key
  minio_server     = module.minio.minio_server
}

resource "vault_kv_secret_v2" "clusters" {
  mount               = "management"
  name                = "clusters"
  delete_all_versions = true

  data_json = jsonencode({
    "app-365zon" = module.cluster-app-365zon-bootstrap.vault_token
  })

  depends_on = [module.vault.installed]
}
