Opinionated.tf/products/postgres/postgres.tf

28 lines
927 B
Terraform
Raw Normal View History

2024-07-29 19:28:08 +00:00
module "service" {
2024-12-31 06:02:31 +00:00
source = "../../docker/service"
image = "${var.postgres_image}:${var.postgres_version}"
stack_name = var.stack_name
2025-01-21 17:18:44 +00:00
service_name = var.service_name
2024-12-31 06:02:31 +00:00
networks = var.networks
healthcheck = ["CMD-SHELL", "pg_isready", "-U", local.username, "-d", local.database]
healthcheck_interval = "10s"
2024-07-29 19:28:08 +00:00
environment_variables = {
POSTGRES_USER = local.username
POSTGRES_PASSWORD = local.password
POSTGRES_DB = local.database
}
2024-11-26 13:42:54 +00:00
volumes = local.volumes
mounts = local.mounts
2024-07-29 19:28:08 +00:00
ports = var.ports
placement_constraints = var.placement_constraints
2024-11-26 13:42:54 +00:00
}
locals {
volumes = var.data_persist_path == null ? {
"data" = "/var/lib/postgres/data"
} : {}
mounts = var.data_persist_path != null ? {
"${var.data_persist_path}" = "/var/lib/postgres/data"
} : {}
2024-07-29 19:28:08 +00:00
}