mirror of
https://gitlab.sarex.io/infra/terraform-contour-mirror.git
synced 2026-08-05 18:31:00 +03:00
- Add infrastructure.yaml as single source of truth (like values.yaml in Helm) - Make all modules universal (no hardcoded entity names) - Use existing PostgreSQL cluster instead of creating new one - Add yc-database module for working with existing PostgreSQL - Add k8s-secret module with lifecycle.ignore_changes support - Update terragrunt.hcl files to read from infrastructure.yaml - Remove scripts, use native Terragrunt functions (yamldecode)
47 lines
1.3 KiB
HCL
47 lines
1.3 KiB
HCL
# Модуль для работы с существующим PostgreSQL кластером
|
||
# Создает базу данных и пользователя в существующем кластере
|
||
|
||
# Генерация пароля для пользователя
|
||
resource "random_password" "user_password" {
|
||
length = var.password_length
|
||
special = var.password_special
|
||
upper = true
|
||
lower = true
|
||
numeric = true
|
||
}
|
||
|
||
# Получение информации о существующем кластере
|
||
data "yandex_mdb_postgresql_cluster" "existing" {
|
||
cluster_id = var.cluster_id
|
||
}
|
||
|
||
# Создание базы данных
|
||
resource "yandex_mdb_postgresql_database" "this" {
|
||
cluster_id = var.cluster_id
|
||
name = var.database_name
|
||
owner = yandex_mdb_postgresql_user.this.name
|
||
lc_collate = var.lc_collate
|
||
lc_type = var.lc_type
|
||
|
||
dynamic "extension" {
|
||
for_each = var.extensions
|
||
content {
|
||
name = extension.value
|
||
}
|
||
}
|
||
}
|
||
|
||
# Создание пользователя
|
||
resource "yandex_mdb_postgresql_user" "this" {
|
||
cluster_id = var.cluster_id
|
||
name = var.user_name
|
||
password = random_password.user_password.result
|
||
|
||
dynamic "permission" {
|
||
for_each = var.permissions
|
||
content {
|
||
database_name = permission.value.database_name
|
||
}
|
||
}
|
||
}
|