fix: zero-value fallback — integer→0, boolean→false; modify uses WithDefaults
This commit is contained in:
@@ -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.0.61"
|
version = "5.1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,28 @@ variable "api_token" {
|
|||||||
sensitive = true
|
sensitive = true
|
||||||
description = "Nubes API token"
|
description = "Nubes API token"
|
||||||
}
|
}
|
||||||
|
variable "s3_uid" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
description = "Nubes S3 UID"
|
||||||
|
}
|
||||||
|
variable "realm" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
description = "resource_realm parameter for nubes_postgres resource"
|
||||||
|
}
|
||||||
|
variable "s3_user_uid" {
|
||||||
|
type = string
|
||||||
|
description = "S3 user UUID"
|
||||||
|
}
|
||||||
|
variable "s3_name" {
|
||||||
|
type = string
|
||||||
|
description = "S3 user name"
|
||||||
|
}
|
||||||
|
|
||||||
provider "nubes" {
|
provider "nubes" {
|
||||||
api_token = var.api_token
|
api_token = var.api_token
|
||||||
api_endpoint = "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc"
|
api_endpoint = "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc"
|
||||||
|
# log_level = "debug" # none | info | debug, default = "none"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
resource "nubes_postgres" "npg_lucee" {
|
||||||
|
resource_name = "pglucee01"
|
||||||
|
|
||||||
|
startup_configuration = {
|
||||||
|
resource_realm = var.realm
|
||||||
|
}
|
||||||
|
|
||||||
|
cluster_configuration = {
|
||||||
|
cpu = 500
|
||||||
|
memory = 512
|
||||||
|
replicas = 1
|
||||||
|
disk = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
access_configuration = {
|
||||||
|
master_ip_space = "no-needed"
|
||||||
|
master_access_list = jsonencode(["10.0.0.0/8"])
|
||||||
|
slave_ip_space = "no-needed"
|
||||||
|
slave_access_list = jsonencode([])
|
||||||
|
}
|
||||||
|
|
||||||
|
postgres_configuration = {
|
||||||
|
version = "17"
|
||||||
|
ssl_required = true
|
||||||
|
pooler_master = false
|
||||||
|
pooler_slave = false
|
||||||
|
}
|
||||||
|
|
||||||
|
postgres_conf = jsonencode([{
|
||||||
|
param_name = "log_connections"
|
||||||
|
param_value = ""
|
||||||
|
}])
|
||||||
|
|
||||||
|
backup_configuration = {
|
||||||
|
s3_uid = var.s3_uid
|
||||||
|
retain = 14
|
||||||
|
schedule = "0 0 * * *"
|
||||||
|
}
|
||||||
|
|
||||||
|
autoscale_configuration = {
|
||||||
|
enabled = false
|
||||||
|
schedule = 0
|
||||||
|
percent = 10
|
||||||
|
quota = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
operation_timeout = "11m"
|
||||||
|
adopt_existing_on_create = true
|
||||||
|
}
|
||||||
@@ -1,58 +1,34 @@
|
|||||||
resource "nubes_postgres" "db2" {
|
|
||||||
resource_name = "pg-tst0"
|
|
||||||
s3_uid = "s01325"
|
|
||||||
# s3_uid = "s3-111805"
|
|
||||||
resource_realm = "k8s-4-sandbox-nubes-ru"
|
|
||||||
# resource_realm = "k8s-3.ext.nubes.ru"
|
|
||||||
resource_instances = 1
|
|
||||||
resource_memory = 512
|
|
||||||
resource_c_p_u = 500
|
|
||||||
resource_disk = "1"
|
|
||||||
app_version = "17"
|
|
||||||
json_parameters = jsonencode({
|
|
||||||
log_connections = "off"
|
|
||||||
log_disconnections = "off"
|
|
||||||
})
|
|
||||||
enable_pg_pooler_master = false
|
|
||||||
enable_pg_pooler_slave = false
|
|
||||||
allow_no_s_s_l = false
|
|
||||||
auto_scale = false
|
|
||||||
auto_scale_percentage = 10
|
|
||||||
auto_scale_tech_window = 0
|
|
||||||
auto_scale_quota_gb = "1"
|
|
||||||
need_external_address_master = false
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "nubes_lucee" "app1" {
|
resource "nubes_lucee" "app1" {
|
||||||
# Lucee-приложение, зависит от Postgres
|
|
||||||
resource_name = "lucy_0"
|
resource_name = "lucy_0"
|
||||||
# resource_realm = "k8s-3.ext.nubes.ru"
|
resource_realm = var.realm
|
||||||
resource_realm = "k8s-4-sandbox-nubes-ru"
|
domain = "tflucee"
|
||||||
domain = "web03"
|
|
||||||
|
|
||||||
# git_path = "https://gitea.services.ngcloud.ru/naeel/testlucee-mirror"
|
git_path = "https://github.com/xahys/testlucee"
|
||||||
# git_path = "https://gitea.services.ngcloud.ru/smishchuk/testlucee"
|
|
||||||
# ⬆️ даёт ошибку, с том числе и при обращении к API by CURL
|
|
||||||
# Приложение не запустилось. Производится полный откат установки.
|
|
||||||
# Ошибка: jlib.k8s [correctReplicaActive] | ERROR | Под(ы) не работают: 'luceek8s' (Deployment).
|
|
||||||
|
|
||||||
# ⬇️ клон "https://gitea.services.ngcloud.ru/smishchuk/testlucee.git"
|
json_env = jsonencode({
|
||||||
git_path = "https://gitea-naeel.giteak8s.services.ngcloud.ru/naeel/testlucee"
|
|
||||||
|
|
||||||
# ⬇️ OK
|
|
||||||
# git_path = "https://github.com/xahys/testlucee"
|
|
||||||
|
|
||||||
json_env = jsonencode({
|
|
||||||
# 🔗 Настройки Data Source 'testds' для Lucee (Application.cfc)
|
# 🔗 Настройки Data Source 'testds' для Lucee (Application.cfc)
|
||||||
testds_class = "org.postgresql.Driver" # 📂 Драйвер БД
|
testds_class = "org.postgresql.Driver"
|
||||||
testds_bundleName = "org.postgresql.jdbc" # 📦 Имя бандла JDBC
|
testds_bundleName = "org.postgresql.jdbc"
|
||||||
testds_bundleVersion = "42.6.0" # 🔢 Версия драйвера
|
testds_bundleVersion = "42.6.0"
|
||||||
testds_connectionString = "jdbc:postgresql://${nubes_postgres.db2.state_out_flat["internalConnect.master"]}:5432/postgres" # 🚀 Строка подключения
|
testds_connectionString = "jdbc:postgresql://${nubes_postgres.npg_lucee.state_out_flat["internalConnect.master"]}:5432/postgres"
|
||||||
testds_username = nubes_postgres.db2.vault_secrets["adminUser"]# 👤 Логин
|
testds_username = nubes_postgres.npg_lucee.vault_secrets["adminUser"]
|
||||||
testds_password = nubes_postgres.db2.vault_secrets["adminPass"] # 🔑 Пароль
|
testds_password = nubes_postgres.npg_lucee.vault_secrets["adminPass"]
|
||||||
testds_connectionLimit = "5" # 🚦 Лимит соединений
|
testds_connectionLimit = "5"
|
||||||
testds_liveTimeout = "15" # ⏳ Таймаут жизни
|
testds_liveTimeout = "15"
|
||||||
testds_validate = "false" # ✅ Валидация при запросе
|
testds_validate = "false"
|
||||||
|
|
||||||
|
# 🐘 Переменные окружения для Lucee (доступны через GetEnv)
|
||||||
|
PGHOST = nubes_postgres.npg_lucee.state_out_flat["internalConnect.master"]
|
||||||
|
PGPORT = "5432"
|
||||||
|
PGUSER = nubes_postgres.npg_lucee.vault_secrets["adminUser"]
|
||||||
|
PGPASSWORD = nubes_postgres.npg_lucee.vault_secrets["adminPass"]
|
||||||
|
PGSSLMODE = "require"
|
||||||
|
DATABASE_URL = format(
|
||||||
|
"postgresql://%s:%s@%s:5432/postgres",
|
||||||
|
nubes_postgres.npg_lucee.vault_secrets["adminUser"],
|
||||||
|
nubes_postgres.npg_lucee.vault_secrets["adminPass"],
|
||||||
|
nubes_postgres.npg_lucee.state_out_flat["internalConnect.master"]
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
resource_c_p_u = 300
|
resource_c_p_u = 300
|
||||||
@@ -60,36 +36,5 @@ json_env = jsonencode({
|
|||||||
resource_instances = 1
|
resource_instances = 1
|
||||||
app_version = "5.4"
|
app_version = "5.4"
|
||||||
|
|
||||||
depends_on = [nubes_postgres.db2]
|
depends_on = [nubes_postgres.npg_lucee]
|
||||||
}
|
|
||||||
|
|
||||||
resource "nubes_nodejs" "app2" {
|
|
||||||
# NodeJS-приложение, использует тот же Postgres
|
|
||||||
resource_name = "node_0"
|
|
||||||
# resource_realm = "k8s-3.ext.nubes.ru"
|
|
||||||
resource_realm = "k8s-4-sandbox-nubes-ru"
|
|
||||||
domain = "node"
|
|
||||||
git_path = "https://gitea-naeel.giteak8s.services.ngcloud.ru/naeel/testnode"
|
|
||||||
health_path = "/healthz"
|
|
||||||
app_version = "23"
|
|
||||||
|
|
||||||
json_env = jsonencode({
|
|
||||||
PGHOST = nubes_postgres.db2.state_out_flat["internalConnect.master"]
|
|
||||||
PGPORT = "5432"
|
|
||||||
PGUSER = nubes_postgres.db2.vault_secrets["adminUser"]
|
|
||||||
PGPASSWORD = nubes_postgres.db2.vault_secrets["adminPass"]
|
|
||||||
PGSSLMODE = "require"
|
|
||||||
DATABASE_URL = format(
|
|
||||||
"postgresql://%s:%s@%s:5432/postgres",
|
|
||||||
nubes_postgres.db2.vault_secrets["adminUser"],
|
|
||||||
nubes_postgres.db2.vault_secrets["adminPass"],
|
|
||||||
nubes_postgres.db2.state_out_flat["internalConnect.master"]
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
resource_c_p_u = 300
|
|
||||||
resource_memory = 256
|
|
||||||
resource_instances = 1
|
|
||||||
|
|
||||||
depends_on = [nubes_postgres.db2]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
api_token = ""
|
api_token = ""
|
||||||
|
s3_uid = ""
|
||||||
|
realm = ""
|
||||||
|
s3_user_uid = ""
|
||||||
|
s3_name = ""
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ variable "s3_user_uid" {
|
|||||||
type = string
|
type = string
|
||||||
description = "S3 user UUID"
|
description = "S3 user UUID"
|
||||||
}
|
}
|
||||||
|
variable "s3_name" {
|
||||||
|
type = string
|
||||||
|
description = "S3 user name"
|
||||||
|
}
|
||||||
|
|
||||||
provider "nubes" {
|
provider "nubes" {
|
||||||
api_token = var.api_token
|
api_token = var.api_token
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
resource "nubes_postgres_user" "pg_user_0" {
|
resource "nubes_postgres_user" "pg_user_0" {
|
||||||
postgres_id = nubes_postgres.npg.id
|
postgres_id = nubes_postgres.npg.id
|
||||||
username = "user0"
|
username = "userinsteadof0"
|
||||||
role = "ddl_user"
|
role = "ddl_user"
|
||||||
adopt_existing_on_create = true
|
adopt_existing_on_create = true
|
||||||
}
|
}
|
||||||
@@ -42,8 +42,8 @@ resource "nubes_postgres_database" "pg_db_2" {
|
|||||||
# S3 bucket — замени "buck0" на своё имя везде ниже
|
# S3 bucket — замени "buck0" на своё имя везде ниже
|
||||||
resource "nubes_s3bucket" "bukka0" { # ← замени buck0 на своё имя ресурса
|
resource "nubes_s3bucket" "bukka0" { # ← замени buck0 на своё имя ресурса
|
||||||
resource_name = "btst" # ← замени buck0 на своё имя ресурса
|
resource_name = "btst" # ← замени buck0 на своё имя ресурса
|
||||||
#s3_user_uid = "naeel-s3"
|
s3_user_uid = var.s3_name
|
||||||
s3_user_uid = var.s3_user_uid
|
# s3_user_uid = var.s3_user_uid
|
||||||
bucket_name = "buck01" # ← замени buck0 на своё имя бакета
|
bucket_name = "buck01" # ← замени buck0 на своё имя бакета
|
||||||
adopt_existing_on_create = true
|
adopt_existing_on_create = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,6 +332,12 @@ func normalizeUniversalValueV6(val string, param universalCfsParam) string {
|
|||||||
if strings.Contains(dataType, "map") || strings.Contains(dataType, "json") || strings.Contains(nameHint, "map") || strings.Contains(nameHint, "json") {
|
if strings.Contains(dataType, "map") || strings.Contains(dataType, "json") || strings.Contains(nameHint, "map") || strings.Contains(nameHint, "json") {
|
||||||
return "{}"
|
return "{}"
|
||||||
}
|
}
|
||||||
|
if strings.Contains(dataType, "integer") || strings.Contains(dataType, "int") {
|
||||||
|
return "0"
|
||||||
|
}
|
||||||
|
if strings.Contains(dataType, "boolean") || strings.Contains(dataType, "bool") {
|
||||||
|
return "false"
|
||||||
|
}
|
||||||
|
|
||||||
return trimmed
|
return trimmed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func UpdateResourceWithTimeout(ctx context.Context, client *core.UniversalClient
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return client.RunInstanceOperationUniversal(ctxWithTimeout, instanceID, "modify", params)
|
return client.RunInstanceOperationUniversalWithDefaults(ctxWithTimeout, instanceID, "modify", params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteResource runs destroy behavior (suspend/state-only) for instance resources.
|
// DeleteResource runs destroy behavior (suspend/state-only) for instance resources.
|
||||||
|
|||||||
Reference in New Issue
Block a user