diff --git a/TEST_STAND/CRUD/flask.tf b/TEST_STAND/CRUD/flask.tf new file mode 100644 index 0000000..70f1b5f --- /dev/null +++ b/TEST_STAND/CRUD/flask.tf @@ -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] +} diff --git a/TEST_STAND/LUCEE/locals.tf b/TEST_STAND/CRUD/locals.tf similarity index 80% rename from TEST_STAND/LUCEE/locals.tf rename to TEST_STAND/CRUD/locals.tf index 627ed64..e1fcf44 100644 --- a/TEST_STAND/LUCEE/locals.tf +++ b/TEST_STAND/CRUD/locals.tf @@ -1,5 +1,5 @@ # ============================================================================= -# locals.tf — все настраиваемые значения модуля LUCEE +# locals.tf — все настраиваемые значения модуля CRUD (PG + Lucee + Flask) # Никакого хардкода в ресурсах — всё здесь. # ============================================================================= @@ -21,7 +21,7 @@ locals { pg_db_name = "db4crudpg" # ─── Lucee ─────────────────────────────────────────────────────────────── - lucee_git_revision = "94d" + lucee_git_revision = "94d6677" lucee_resource_name = "luceeresource" lucee_domain = "tflucee" lucee_version = "5.4" @@ -33,6 +33,15 @@ locals { # ─── Таблица CRUD ──────────────────────────────────────────────────────── 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_class = "org.postgresql.Driver" jdbc_bundle_name = "org.postgresql.jdbc" diff --git a/TEST_STAND/LUCEE/lucee.tf b/TEST_STAND/CRUD/lucee.tf similarity index 87% rename from TEST_STAND/LUCEE/lucee.tf rename to TEST_STAND/CRUD/lucee.tf index 57daf86..85d2e25 100644 --- a/TEST_STAND/LUCEE/lucee.tf +++ b/TEST_STAND/CRUD/lucee.tf @@ -1,7 +1,7 @@ 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_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 } @@ -55,5 +55,5 @@ resource "nubes_lucee" "applucee" { ) }) - depends_on = [nubes_postgres.npg_lucee] + depends_on = [nubes_postgres.main_pg] } diff --git a/TEST_STAND/LUCEE/main.tf b/TEST_STAND/CRUD/main.tf similarity index 97% rename from TEST_STAND/LUCEE/main.tf rename to TEST_STAND/CRUD/main.tf index c0e4bad..89fcf56 100644 --- a/TEST_STAND/LUCEE/main.tf +++ b/TEST_STAND/CRUD/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { nubes = { source = "registry.kube5s.ru/nubes-test/nubes" - version = "5.1.15" + version = "5.1.16" } } } diff --git a/TEST_STAND/LUCEE/nubes_postgres_lucee.tf b/TEST_STAND/CRUD/postgres.tf similarity index 96% rename from TEST_STAND/LUCEE/nubes_postgres_lucee.tf rename to TEST_STAND/CRUD/postgres.tf index 834e25b..60dddb0 100644 --- a/TEST_STAND/LUCEE/nubes_postgres_lucee.tf +++ b/TEST_STAND/CRUD/postgres.tf @@ -1,4 +1,4 @@ -resource "nubes_postgres" "npg_lucee" { +resource "nubes_postgres" "main_pg" { resource_name = local.pg_resource_name startup_configuration = { diff --git a/TEST_STAND/LUCEE/userUNDdb.tf b/TEST_STAND/CRUD/postgres_user_db.tf similarity index 83% rename from TEST_STAND/LUCEE/userUNDdb.tf rename to TEST_STAND/CRUD/postgres_user_db.tf index 2ee8cfd..cb6c72b 100644 --- a/TEST_STAND/LUCEE/userUNDdb.tf +++ b/TEST_STAND/CRUD/postgres_user_db.tf @@ -2,14 +2,14 @@ # PostgreSQL — пользователи и базы данных # ============================================================================= 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 role = local.pg_role adopt_existing_on_create = true } 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_owner = nubes_postgres_user.crud_user_0.username adopt_existing_on_create = true diff --git a/TEST_STAND/LUCEE/terraform.tfvars.example b/TEST_STAND/CRUD/terraform.tfvars.example similarity index 100% rename from TEST_STAND/LUCEE/terraform.tfvars.example rename to TEST_STAND/CRUD/terraform.tfvars.example