2023-03-17 04:14:39 +00:00
|
|
|
variable "environment" {}
|
|
|
|
variable "namespace" {}
|
|
|
|
variable "region" {}
|
|
|
|
variable "out_dir" {
|
|
|
|
type = string
|
2023-05-05 03:31:53 +00:00
|
|
|
default = "../../out"
|
2023-01-28 03:08:56 +00:00
|
|
|
}
|
2023-03-17 04:14:39 +00:00
|
|
|
|
|
|
|
resource "random_id" "suffix" {
|
2023-04-14 03:22:35 +00:00
|
|
|
byte_length = 8
|
2023-01-28 03:08:56 +00:00
|
|
|
}
|
2023-05-09 11:32:53 +00:00
|
|
|
|
|
|
|
resource "digitalocean_custom_image" "talos" {
|
|
|
|
name = "talos"
|
2023-05-10 23:24:07 +00:00
|
|
|
url = "https://github.com/siderolabs/talos/releases/download/v1.4.3/digital-ocean-amd64.raw.gz"
|
2023-05-12 04:33:41 +00:00
|
|
|
# this gets reset by DigitalOcean
|
|
|
|
distribution = "Unknown OS"
|
2023-05-12 03:21:25 +00:00
|
|
|
regions = [var.region]
|
2023-05-09 11:32:53 +00:00
|
|
|
}
|
|
|
|
|
2023-05-10 23:24:07 +00:00
|
|
|
module "digitalocean_talos_cluster-2" {
|
2023-05-09 11:32:53 +00:00
|
|
|
source = "../../terraform_modules/digitalocean_talos_cluster"
|
|
|
|
|
|
|
|
talos_cluster_name = "distrust"
|
|
|
|
talos_image = digitalocean_custom_image.talos.image_id
|
|
|
|
talos_config_directory = "talos"
|
2023-05-10 23:24:07 +00:00
|
|
|
control_plane_pool = {
|
|
|
|
count = 1,
|
|
|
|
size = "s-4vcpu-8gb",
|
|
|
|
}
|
2023-05-09 11:32:53 +00:00
|
|
|
worker_pools = [{
|
|
|
|
name = "primary",
|
|
|
|
count = 1,
|
|
|
|
size = "s-2vcpu-4gb",
|
|
|
|
}]
|
2023-05-12 04:33:41 +00:00
|
|
|
digitalocean_region = var.region
|
|
|
|
}
|
|
|
|
|
|
|
|
module "digitalocean_database_cluster" {
|
|
|
|
source = "../../terraform_modules/digitalocean_database_cluster"
|
|
|
|
|
|
|
|
cluster_name = "distrust"
|
|
|
|
db_engine = "pg"
|
|
|
|
db_version = "15"
|
|
|
|
size = "db-s-1vcpu-2gb"
|
|
|
|
node_count = 1
|
|
|
|
|
|
|
|
databases = [{
|
|
|
|
name = "keycloak",
|
|
|
|
create_default_superuser = true,
|
|
|
|
}, {
|
|
|
|
name = "forgejo",
|
|
|
|
create_default_superuser = true,
|
|
|
|
}]
|
|
|
|
|
|
|
|
vpc_id = module.digitalocean_talos_cluster-2.vpc_id
|
|
|
|
digitalocean_region = var.region
|
|
|
|
}
|
|
|
|
|
|
|
|
# TODO: make it output a Kubernetes Secret in env var format, can be piped into
|
|
|
|
# `jq .database_users.value.forgejo | sops --encrypt` for nice secret gen
|
|
|
|
# Ref: https://github.com/RyanSquared/gitops/blob/b8305292f215f6fe0bed170550b9b869302ab9e2/environments/production/kustomizations/forgejo/forgejo-config.enc.yaml
|
|
|
|
output "database_users" {
|
|
|
|
value = module.digitalocean_database_cluster.database_users
|
|
|
|
sensitive = true
|
2023-05-09 11:32:53 +00:00
|
|
|
}
|