terraform {
  required_version = "~> 1.3.5"

  backend "s3" {
    bucket                      = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05"
    key                         = "concourse/terraform.tfstate"
    region                      = "eu-central-1"
    skip_region_validation      = true
    skip_credentials_validation = true
    skip_metadata_api_check     = true
    endpoint                    = "eu-central-1.linodeobjects.com"
  }

  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "2.23.1"
    }
    linode = {
      source  = "linode/linode"
      version = "1.29.4"
    }
    postgresql = {
      source  = "cyrilgdn/postgresql"
      version = "1.18.0"
    }
    sops = {
      source  = "lokkersp/sops"
      version = "0.6.10"
    }
  }
}

provider "docker" {
  host = "ssh://conflatorio.vpn.trygvis.io"
}

provider "postgresql" {
  host     = "knot.vpn.trygvis.io"
  database = "postgres"
  username = "terraform"
  password = data.sops_file_entry.knot_pdb_terraform_password.data
  sslmode  = "require"
}

provider "sops" {
  age = {
    key = "age13wv3rp0varlg4nvt3tca48fq8u9q3mc6yfdekjeapcmc7kaq4dysrzcmv3"
  }
}

locals {
  domain_name = "concourse.vpn.trygvis.io"
}

data "sops_file_entry" "knot_pdb_terraform_password" {
  source_file = "../../sops.yml"
  data_key    = "knot_pdb_terraform_password"
}