Раньше CRUD лежал плоской схемой (main.tf, locals.tf, postgres*.tf, три
приложения в одной папке) и версия провайдера в нём была 5.1.16 — из-за этого
опубликованная страница документации не могла ссылаться на этот репозиторий
(в ней описаны два каталога pg/ и apps/).
Что сделано:
- старые файлы плоской схемы удалены;
- добавлены pg/{main.tf,postgres.tf,postgres_user_db.tf,outputs.tf,
terraform.tfvars.example} и apps/{main.tf,locals.tf,lucee.tf,flask.tf,
nodejs.tf,.gitignore,terraform.tfvars.example} — из стенда TEST_STAND/CRUD;
- README.md — тот же пользовательский текст, но клонирование теперь
git clone https://gitea.services.ngcloud.ru/Nail/tf_examples.git && cd tf_examples/CRUD;
- провайдер в pg/main.tf и apps/main.tf: nubes-test/nubes 3.0.0.
Секреты не переносились: взяты только отслеживаемые git файлы стенда,
terraform.tfvars и apps/creds.json в репозиторий не попадали.
Проверено: 13 файлов в CRUD, .gitignore закрывает terraform.tfvars, creds.json,
tfstate.
86 lines
6.0 KiB
Terraform
86 lines
6.0 KiB
Terraform
# =============================================================================
|
|
# APPS — все настраиваемые значения + чтение кредов БД
|
|
# =============================================================================
|
|
|
|
locals {
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# КРЕДЫ БД — берутся из файла, выгруженного из папки ../pg/
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
#
|
|
# Порядок (см. ../README.md):
|
|
# 1) cd ../pg && terraform apply
|
|
# 2) cd ../pg && terraform output -json > ../apps/creds.json
|
|
# 3) cd ../apps && terraform apply
|
|
#
|
|
# Почему через файл: pg/ и apps/ — РАЗНЫЕ состояния Terraform, значения между
|
|
# ними сами не передаются. Поэтому креды передаются явной выгрузкой outputs → файлом.
|
|
#
|
|
# Структура creds.json (так отдаёт `terraform output -json`):
|
|
# { "pg_host": { "sensitive": false, "type": "string", "value": "..." }, ... }
|
|
# Отсюда и обращение `local.creds.pg_host.value`.
|
|
#
|
|
# Пароль в открытом виде! Файл в .gitignore — в git не коммитить.
|
|
# При ротации пароля (повторный create_user) — перегенерить файл шагом 2.
|
|
creds = jsondecode(file("${path.module}/creds.json"))
|
|
|
|
pg_host = local.creds.pg_host.value
|
|
pg_port = local.creds.pg_port.value
|
|
pg_user = local.creds.pg_username.value
|
|
pg_pass = local.creds.pg_password.value
|
|
pg_db = local.creds.pg_db_name.value
|
|
pg_ssl = local.creds.pg_ssl_mode.value
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# Общая таблица CRUD — одна на все три приложения
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
crud_table_name = "crud_items"
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# Lucee — CFML-приложение (сервис 94)
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
lucee_resource_name = "lucee-crud" # имя ресурса в Nubes
|
|
lucee_domain = "lucee-crud" # домен → lucee-crud.luceek8s.dev.nubes.ru. Прежний tflucee занят старым инстансом
|
|
lucee_version = "5.4"
|
|
lucee_git_path = "https://gitea.services.ngcloud.ru/terraform/tfluceecrud.git"
|
|
lucee_cpu = 300
|
|
lucee_memory = 512
|
|
lucee_replicas = 1
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# Flask — Python-приложение (сервис 89)
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
flask_resource_name = "flask-crud"
|
|
flask_domain = "flask-crud" # → flask-crud.pythonk8s.dev.nubes.ru. Прежний tfflask занят старым инстансом
|
|
flask_git_path = "https://gitea.services.ngcloud.ru/terraform/tfflaskcrud.git"
|
|
flask_cpu = 300
|
|
flask_memory = 512
|
|
flask_replicas = 1
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# Node.js — Express-приложение (сервис 95)
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
nodejs_resource_name = "nodejs-crud"
|
|
nodejs_domain = "nodejs-crud" # → nodejs-crud.<суффикс>.dev.nubes.ru. Прежний tfnodejs занят старым инстансом
|
|
nodejs_git_path = "https://gitea.services.ngcloud.ru/terraform/tfnodejscrud.git"
|
|
nodejs_cpu = 300
|
|
nodejs_memory = 512
|
|
nodejs_replicas = 1
|
|
nodejs_timeout = "15m"
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# JDBC — параметры подключения Lucee к PostgreSQL
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
jdbc_class = "org.postgresql.Driver"
|
|
jdbc_bundle_name = "org.postgresql.jdbc"
|
|
jdbc_bundle_version = "42.6.0"
|
|
jdbc_conn_limit = "5"
|
|
jdbc_live_timeout = "15"
|
|
jdbc_validate = "false"
|
|
}
|