refactor: LUCEE/ → CRUD/, npg_lucee → main_pg, add flask.tf
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# Flask — CRUD (та же PG, та же таблица что у Lucee)
|
||||||
|
# =============================================================================
|
||||||
|
locals {
|
||||||
|
# Повторно используем pg_host/pg_user/pg_pass/pg_db из lucee.tf locals
|
||||||
|
flask_pg_host = nubes_postgres.main_pg.state_out_flat["internalMaster"]
|
||||||
|
flask_pg_user = nubes_postgres_user.crud_user_0.username
|
||||||
|
flask_pg_pass = nonsensitive(jsondecode(nubes_postgres.main_pg.vault_secrets["users"]).user4crudpg.password)
|
||||||
|
flask_pg_db = nubes_postgres_database.pg_db.db_name
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "nubes_flask" "appflask" {
|
||||||
|
resource_name = local.flask_resource_name
|
||||||
|
|
||||||
|
startup_configuration = {
|
||||||
|
resource_realm = var.realm
|
||||||
|
}
|
||||||
|
|
||||||
|
cluster_configuration = {
|
||||||
|
cpu = local.flask_cpu
|
||||||
|
memory = local.flask_memory
|
||||||
|
replicas = local.flask_replicas
|
||||||
|
}
|
||||||
|
|
||||||
|
access_configuration = {
|
||||||
|
domain = local.flask_domain
|
||||||
|
}
|
||||||
|
|
||||||
|
app_configuration = {
|
||||||
|
version = "3.12"
|
||||||
|
git_path = local.flask_git_path
|
||||||
|
health_path = "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
git_revision = local.flask_git_revision
|
||||||
|
|
||||||
|
json_env = jsonencode({
|
||||||
|
TABLE_NAME = local.crud_table_name
|
||||||
|
PGHOST = local.flask_pg_host
|
||||||
|
PGPORT = local.pg_port
|
||||||
|
PGUSER = local.flask_pg_user
|
||||||
|
PGPASSWORD = local.flask_pg_pass
|
||||||
|
PGDATABASE = local.flask_pg_db
|
||||||
|
PGSSLMODE = local.pg_ssl_mode
|
||||||
|
})
|
||||||
|
|
||||||
|
depends_on = [nubes_postgres.main_pg]
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
# locals.tf — все настраиваемые значения модуля LUCEE
|
# locals.tf — все настраиваемые значения модуля CRUD (PG + Lucee + Flask)
|
||||||
# Никакого хардкода в ресурсах — всё здесь.
|
# Никакого хардкода в ресурсах — всё здесь.
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ locals {
|
|||||||
pg_db_name = "db4crudpg"
|
pg_db_name = "db4crudpg"
|
||||||
|
|
||||||
# ─── Lucee ───────────────────────────────────────────────────────────────
|
# ─── Lucee ───────────────────────────────────────────────────────────────
|
||||||
lucee_git_revision = "94d"
|
lucee_git_revision = "94d6677"
|
||||||
lucee_resource_name = "luceeresource"
|
lucee_resource_name = "luceeresource"
|
||||||
lucee_domain = "tflucee"
|
lucee_domain = "tflucee"
|
||||||
lucee_version = "5.4"
|
lucee_version = "5.4"
|
||||||
@@ -33,6 +33,15 @@ locals {
|
|||||||
# ─── Таблица CRUD ────────────────────────────────────────────────────────
|
# ─── Таблица CRUD ────────────────────────────────────────────────────────
|
||||||
crud_table_name = "crud_items"
|
crud_table_name = "crud_items"
|
||||||
|
|
||||||
|
# ─── Flask ───────────────────────────────────────────────────────────────
|
||||||
|
flask_git_revision = "9c14f70"
|
||||||
|
flask_resource_name = "flaskcrud"
|
||||||
|
flask_domain = "tfflask"
|
||||||
|
flask_git_path = "https://gitea.services.ngcloud.ru/Nail/tfflaskcrud.git"
|
||||||
|
flask_cpu = 300
|
||||||
|
flask_memory = 512
|
||||||
|
flask_replicas = 1
|
||||||
|
|
||||||
# ─── JDBC / БД ───────────────────────────────────────────────────────────
|
# ─── JDBC / БД ───────────────────────────────────────────────────────────
|
||||||
jdbc_class = "org.postgresql.Driver"
|
jdbc_class = "org.postgresql.Driver"
|
||||||
jdbc_bundle_name = "org.postgresql.jdbc"
|
jdbc_bundle_name = "org.postgresql.jdbc"
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
locals {
|
locals {
|
||||||
pg_host = nubes_postgres.npg_lucee.state_out_flat["internalMaster"]
|
pg_host = nubes_postgres.main_pg.state_out_flat["internalMaster"]
|
||||||
pg_user = nubes_postgres_user.crud_user_0.username
|
pg_user = nubes_postgres_user.crud_user_0.username
|
||||||
pg_pass = nonsensitive(jsondecode(nubes_postgres.npg_lucee.vault_secrets["users"]).user4crudpg.password)
|
pg_pass = nonsensitive(jsondecode(nubes_postgres.main_pg.vault_secrets["users"]).user4crudpg.password)
|
||||||
pg_db = nubes_postgres_database.pg_db.db_name
|
pg_db = nubes_postgres_database.pg_db.db_name
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,5 +55,5 @@ resource "nubes_lucee" "applucee" {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
depends_on = [nubes_postgres.npg_lucee]
|
depends_on = [nubes_postgres.main_pg]
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
nubes = {
|
nubes = {
|
||||||
source = "registry.kube5s.ru/nubes-test/nubes"
|
source = "registry.kube5s.ru/nubes-test/nubes"
|
||||||
version = "5.1.15"
|
version = "5.1.16"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
resource "nubes_postgres" "npg_lucee" {
|
resource "nubes_postgres" "main_pg" {
|
||||||
resource_name = local.pg_resource_name
|
resource_name = local.pg_resource_name
|
||||||
|
|
||||||
startup_configuration = {
|
startup_configuration = {
|
||||||
@@ -2,14 +2,14 @@
|
|||||||
# PostgreSQL — пользователи и базы данных
|
# PostgreSQL — пользователи и базы данных
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
resource "nubes_postgres_user" "crud_user_0" {
|
resource "nubes_postgres_user" "crud_user_0" {
|
||||||
postgres_id = nubes_postgres.npg_lucee.id
|
postgres_id = nubes_postgres.main_pg.id
|
||||||
username = local.pg_username
|
username = local.pg_username
|
||||||
role = local.pg_role
|
role = local.pg_role
|
||||||
adopt_existing_on_create = true
|
adopt_existing_on_create = true
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "nubes_postgres_database" "pg_db" {
|
resource "nubes_postgres_database" "pg_db" {
|
||||||
postgres_id = nubes_postgres.npg_lucee.id
|
postgres_id = nubes_postgres.main_pg.id
|
||||||
db_name = local.pg_db_name
|
db_name = local.pg_db_name
|
||||||
db_owner = nubes_postgres_user.crud_user_0.username
|
db_owner = nubes_postgres_user.crud_user_0.username
|
||||||
adopt_existing_on_create = true
|
adopt_existing_on_create = true
|
||||||
Reference in New Issue
Block a user