terraform {
  required_providers {
    minio = {
      source  = "aminueza/minio"
      version = "~> 2.5.0"
    }
    hcloud = {
      source  = "hetznercloud/hcloud"
      version = "~> 1.45"
    }
  }
}

provider "minio" {
  minio_server   = var.minio_server
  minio_region   = var.region
  minio_user     = var.access_key
  minio_password = var.secret_key
  minio_ssl      = true
}

data "minio_s3_object" "k8s_yaml" {
  bucket_name = var.bucket
  object_name = "kube_config.yaml"
}

data "minio_s3_object" "id_rsa" {
  bucket_name = var.bucket
  object_name = "id_rsa"
}

data "minio_s3_object" "id_rsa_pub" {
  bucket_name = var.bucket
  object_name = "id_rsa.pub"
}

provider "vault" {
  address = var.vault_addr
  token   = var.vault_token
}

data "vault_kv_secret_v2" "hcloud" {
  mount = var.bucket
  name  = "hcloud"
}

data "vault_kv_secret_v2" "clusters" {
  mount = var.bucket
  name  = "clusters"
}

data "vault_kv_secret_v2" "rancher" {
  mount = var.bucket
  name  = "rancher"
}
