From 227c4604d6fb9049505a7fb03aa638c16a3db4c0 Mon Sep 17 00:00:00 2001 From: Marco Mari <130982006+mamari90@users.noreply.github.com> Date: Wed, 11 Dec 2024 12:49:18 +0100 Subject: [PATCH] feat: Paymcloud 152 printit mono az (#2647) --- .../01_app_service_pdf_engine_clone.tf | 480 ++++++++++++++++++ src/domains/printit-app/04_apim_pdf_engine.tf | 4 +- src/domains/printit-app/99_variables.tf | 13 +- src/domains/printit-app/README.md | 9 +- .../printit-app/env/itn-prod/terraform.tfvars | 6 +- .../shared-app/01_app_service_pdf_engine.tf | 20 +- src/domains/shared-app/04_apim_pdf_engine.tf | 4 +- src/domains/shared-app/99_variables.tf | 6 + src/domains/shared-app/README.md | 1 + .../shared-app/env/weu-prod/terraform.tfvars | 1 + 10 files changed, 523 insertions(+), 21 deletions(-) create mode 100644 src/domains/printit-app/01_app_service_pdf_engine_clone.tf diff --git a/src/domains/printit-app/01_app_service_pdf_engine_clone.tf b/src/domains/printit-app/01_app_service_pdf_engine_clone.tf new file mode 100644 index 000000000..9854bfc53 --- /dev/null +++ b/src/domains/printit-app/01_app_service_pdf_engine_clone.tf @@ -0,0 +1,480 @@ +resource "azurerm_resource_group" "printit_pdf_engine_app_service_rg_clone" { + count = var.is_feature_enabled.pdf_engine_clone ? 1 : 0 + name = "${local.project}-pdf-engine-clone-rg" + location = var.location + + tags = var.tags +} + +################ +# node +################ + +module "printit_pdf_engine_app_service_clone" { + source = "./.terraform/modules/__v3__/app_service" + + count = var.is_feature_enabled.pdf_engine_clone ? 1 : 0 + + vnet_integration = false + resource_group_name = azurerm_resource_group.printit_pdf_engine_app_service_rg_clone[0].name + location = var.location + + # App service plan vars + plan_name = "${local.project}-plan-pdf-engine-clone" + sku_name = var.app_service_pdf_engine_sku_name + + # App service plan + name = "${local.project}-app-pdf-engine-clone" + client_cert_enabled = false + always_on = var.app_service_pdf_engine_always_on + + docker_image = "${data.azurerm_container_registry.container_registry.login_server}/pagopapdfengine" + docker_image_tag = "latest" + + health_check_path = "/info" + + ip_restriction_default_action = var.app_service_ip_restriction_default_action + + + app_settings = local.printit_pdf_engine_app_settings + + zone_balancing_enabled = false + allowed_subnets = [data.azurerm_subnet.apim_vnet.id] + allowed_ips = [] + + subnet_id = data.azurerm_subnet.printit_pdf_engine_app_service_snet[0].id + + tags = var.tags + +} + +module "printit_pdf_engine_slot_staging_clone" { + count = var.env_short != "d" && var.is_feature_enabled.pdf_engine_clone ? 1 : 0 + + source = "./.terraform/modules/__v3__/app_service_slot" + + # App service plan + # app_service_plan_id = module.printit_pdf_engine_app_service.plan_id + app_service_id = module.printit_pdf_engine_app_service_clone[0].id + app_service_name = module.printit_pdf_engine_app_service_clone[0].name + + # App service + name = "staging" + resource_group_name = azurerm_resource_group.printit_pdf_engine_app_service_rg_clone[0].name + location = var.location + + always_on = true + docker_image = "${data.azurerm_container_registry.container_registry.login_server}/pagopapdfengine" + docker_image_tag = "latest" + health_check_path = "/info" + + + # App settings + app_settings = local.printit_pdf_engine_app_settings + + allowed_subnets = [data.azurerm_subnet.apim_vnet.id] + allowed_ips = [] + subnet_id = data.azurerm_subnet.printit_pdf_engine_app_service_snet[0].id + + tags = var.tags + + +} + +resource "azurerm_monitor_autoscale_setting" "autoscale_app_service_printit_pdf_engine_autoscale_clone" { + count = var.env_short != "d" && var.is_feature_enabled.pdf_engine_clone ? 1 : 0 + enabled = var.app_service_pdf_engine_autoscale_enabled + + name = "${local.project}-autoscale-pdf-engine-clone" + resource_group_name = azurerm_resource_group.printit_pdf_engine_app_service_rg_clone[0].name + location = azurerm_resource_group.printit_pdf_engine_app_service_rg_clone[0].location + target_resource_id = module.printit_pdf_engine_app_service_clone[0].plan_id + + profile { + name = "default" + + capacity { + default = 3 + minimum = var.env_short == "p" ? 3 : 1 + maximum = 10 + } + + # Requests + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.printit_pdf_engine_app_service_clone[0].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "GreaterThan" + threshold = 2000 + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT5M" + } + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.printit_pdf_engine_app_service_clone[0].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 1000 + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT20M" + } + } + + # HttpResponseTime + + # Supported metrics for Microsoft.Web/sites + # 👀 https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-web-sites-metrics + rule { + metric_trigger { + metric_name = "HttpResponseTime" + metric_resource_id = module.printit_pdf_engine_app_service_clone[0].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "GreaterThan" + threshold = 5 #sec + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT5M" + } + } + + rule { + metric_trigger { + metric_name = "HttpResponseTime" + metric_resource_id = module.printit_pdf_engine_app_service_clone[0].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 2 #sec + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT20M" + } + } + + # CpuPercentage + + # Supported metrics for Microsoft.Web/sites + # 👀 https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-web-sites-metrics + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.printit_pdf_engine_app_service_clone[0].plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "GreaterThan" + threshold = 75 + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT5M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.printit_pdf_engine_app_service_clone[0].plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 30 #sec + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT20M" + } + } + + + } +} + + +############### +#java +############### +module "printit_pdf_engine_app_service_java_clone" { + source = "./.terraform/modules/__v3__/app_service" + count = var.is_feature_enabled.pdf_engine_clone ? 1 : 0 + + vnet_integration = false + resource_group_name = azurerm_resource_group.printit_pdf_engine_app_service_rg_clone[0].name + location = var.location + + # App service plan vars + plan_name = "${local.project}-plan-pdf-engine-java-clone" + sku_name = var.app_service_pdf_engine_sku_name_java + zone_balancing_enabled = false + + # App service plan + name = "${local.project}-app-pdf-engine-java-clone" + client_cert_enabled = false + always_on = var.app_service_pdf_engine_always_on + docker_image = "${data.azurerm_container_registry.container_registry.login_server}/pagopapdfenginejava" + docker_image_tag = "latest" + + health_check_path = "/info" + + app_settings = local.printit_pdf_engine_app_settings_java + + ip_restriction_default_action = var.app_service_ip_restriction_default_action + allowed_subnets = [data.azurerm_subnet.apim_vnet.id] + allowed_ips = [] + + subnet_id = data.azurerm_subnet.printit_pdf_engine_app_service_snet[0].id + + tags = var.tags + + +} + +module "printit_pdf_engine_java_slot_staging_clone" { + count = var.env_short != "d" && var.is_feature_enabled.pdf_engine_clone ? 1 : 0 + + source = "./.terraform/modules/__v3__/app_service_slot" + + # App service plan + # app_service_plan_id = module.printit_pdf_engine_app_service.plan_id + app_service_id = module.printit_pdf_engine_app_service_java_clone[0].id + app_service_name = module.printit_pdf_engine_app_service_java_clone[0].name + + # App service + name = "staging" + resource_group_name = azurerm_resource_group.printit_pdf_engine_app_service_rg_clone[0].name + location = var.location + + always_on = true + docker_image = "${data.azurerm_container_registry.container_registry.login_server}/pagopapdfenginejava" + docker_image_tag = "latest" + health_check_path = "/info" + + + # App settings + app_settings = local.printit_pdf_engine_app_settings_java + + allowed_subnets = [data.azurerm_subnet.apim_vnet.id] + allowed_ips = [] + subnet_id = data.azurerm_subnet.printit_pdf_engine_app_service_snet[0].id + + tags = var.tags + + +} + +resource "azurerm_monitor_autoscale_setting" "autoscale_app_service_printit_pdf_engine_java_autoscale_clone" { + count = var.env_short != "d" && var.is_feature_enabled.pdf_engine_clone ? 1 : 0 + + + name = "${local.project}-autoscale-pdf-engine-java-clone" + resource_group_name = azurerm_resource_group.printit_pdf_engine_app_service_rg_clone[0].name + location = azurerm_resource_group.printit_pdf_engine_app_service_rg_clone[0].location + target_resource_id = module.printit_pdf_engine_app_service_java_clone[0].plan_id + enabled = var.app_service_pdf_engine_autoscale_enabled + + profile { + name = "default" + + capacity { + default = 3 + minimum = var.env_short == "p" ? 3 : 1 + maximum = 10 + } + + # Requests + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.printit_pdf_engine_app_service_java_clone[0].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "GreaterThan" + threshold = 2000 + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT5M" + } + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.printit_pdf_engine_app_service_java_clone[0].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 1000 + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT20M" + } + } + + # HttpResponseTime + + # Supported metrics for Microsoft.Web/sites + # 👀 https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-web-sites-metrics + rule { + metric_trigger { + metric_name = "HttpResponseTime" + metric_resource_id = module.printit_pdf_engine_app_service_java_clone[0].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "GreaterThan" + threshold = 5 #sec + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT5M" + } + } + + rule { + metric_trigger { + metric_name = "HttpResponseTime" + metric_resource_id = module.printit_pdf_engine_app_service_java_clone[0].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 2 #sec + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT20M" + } + } + + # CpuPercentage + + # Supported metrics for Microsoft.Web/sites + # 👀 https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-web-sites-metrics + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.printit_pdf_engine_app_service_java_clone[0].plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "GreaterThan" + threshold = 75 + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT5M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.printit_pdf_engine_app_service_java_clone[0].plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 30 #sec + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT20M" + } + } + } +} + diff --git a/src/domains/printit-app/04_apim_pdf_engine.tf b/src/domains/printit-app/04_apim_pdf_engine.tf index 128494910..60de6096e 100644 --- a/src/domains/printit-app/04_apim_pdf_engine.tf +++ b/src/domains/printit-app/04_apim_pdf_engine.tf @@ -31,7 +31,7 @@ locals { description = "PDF Engine Service for Stampa Avvisi - API" path = "printit/pdf-engine" subscription_required = true - service_url = can(module.printit_pdf_engine_app_service_java[0].default_site_hostname) ? module.printit_pdf_engine_app_service_java[0].default_site_hostname : "" + service_url = var.is_feature_enabled.apim_use_pdf_engine_clone ? (can(module.printit_pdf_engine_app_service_java_clone[0].default_site_hostname) ? module.printit_pdf_engine_app_service_java_clone[0].default_site_hostname : "") : (can(module.printit_pdf_engine_app_service_java[0].default_site_hostname) ? module.printit_pdf_engine_app_service_java[0].default_site_hostname : "") } apim_pdf_engine_node_service_api = { # node @@ -39,7 +39,7 @@ locals { description = "PDF Engine Node Service for Stampa Avvisi - API" path = "printit/pdf-engine-node" subscription_required = true - service_url = can(module.printit_pdf_engine_app_service[0].default_site_hostname) ? module.printit_pdf_engine_app_service[0].default_site_hostname : "" + service_url = var.is_feature_enabled.apim_use_pdf_engine_clone ? (can(module.printit_pdf_engine_app_service_clone[0].default_site_hostname) ? module.printit_pdf_engine_app_service_clone[0].default_site_hostname : "") : (can(module.printit_pdf_engine_app_service[0].default_site_hostname) ? module.printit_pdf_engine_app_service[0].default_site_hostname : "") } } diff --git a/src/domains/printit-app/99_variables.tf b/src/domains/printit-app/99_variables.tf index db7a8f75f..ae8f59e2a 100644 --- a/src/domains/printit-app/99_variables.tf +++ b/src/domains/printit-app/99_variables.tf @@ -71,12 +71,16 @@ variable "tags" { variable "is_feature_enabled" { type = object({ - pdf_engine = bool - printit = bool + pdf_engine = bool + printit = bool + apim_use_pdf_engine_clone = optional(bool, false) + pdf_engine_clone = optional(bool, false) }) default = { - pdf_engine = false - printit = false + pdf_engine = false + printit = false + apim_use_pdf_engine_clone = false + pdf_engine_clone = false } } ### External resources @@ -223,3 +227,4 @@ variable "app_service_ip_restriction_default_action" { default = "Allow" description = "(Optional) The Default action for traffic that does not match any ip_restriction rule. possible values include Allow and Deny. Defaults to Allow." } + diff --git a/src/domains/printit-app/README.md b/src/domains/printit-app/README.md index a649ffcd0..3efa080e8 100644 --- a/src/domains/printit-app/README.md +++ b/src/domains/printit-app/README.md @@ -145,9 +145,13 @@ No outputs. | [kubernetes\_service\_account](#module\_kubernetes\_service\_account) | ./.terraform/modules/__v3__/kubernetes_service_account | n/a | | [pod\_identity](#module\_pod\_identity) | ./.terraform/modules/__v3__/kubernetes_pod_identity | n/a | | [printit\_pdf\_engine\_app\_service](#module\_printit\_pdf\_engine\_app\_service) | ./.terraform/modules/__v3__/app_service | n/a | +| [printit\_pdf\_engine\_app\_service\_clone](#module\_printit\_pdf\_engine\_app\_service\_clone) | ./.terraform/modules/__v3__/app_service | n/a | | [printit\_pdf\_engine\_app\_service\_java](#module\_printit\_pdf\_engine\_app\_service\_java) | ./.terraform/modules/__v3__/app_service | n/a | +| [printit\_pdf\_engine\_app\_service\_java\_clone](#module\_printit\_pdf\_engine\_app\_service\_java\_clone) | ./.terraform/modules/__v3__/app_service | n/a | | [printit\_pdf\_engine\_java\_slot\_staging](#module\_printit\_pdf\_engine\_java\_slot\_staging) | ./.terraform/modules/__v3__/app_service_slot | n/a | +| [printit\_pdf\_engine\_java\_slot\_staging\_clone](#module\_printit\_pdf\_engine\_java\_slot\_staging\_clone) | ./.terraform/modules/__v3__/app_service_slot | n/a | | [printit\_pdf\_engine\_slot\_staging](#module\_printit\_pdf\_engine\_slot\_staging) | ./.terraform/modules/__v3__/app_service_slot | n/a | +| [printit\_pdf\_engine\_slot\_staging\_clone](#module\_printit\_pdf\_engine\_slot\_staging\_clone) | ./.terraform/modules/__v3__/app_service_slot | n/a | | [tls\_checker](#module\_tls\_checker) | ./.terraform/modules/__v3__/tls_checker | n/a | ## Resources @@ -186,7 +190,9 @@ No outputs. | [azurerm_key_vault_secret.templates_storage_account_pkey](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) | resource | | [azurerm_key_vault_secret.tenant_id](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) | resource | | [azurerm_monitor_autoscale_setting.autoscale_app_service_printit_pdf_engine_autoscale](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting) | resource | +| [azurerm_monitor_autoscale_setting.autoscale_app_service_printit_pdf_engine_autoscale_clone](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting) | resource | | [azurerm_monitor_autoscale_setting.autoscale_app_service_printit_pdf_engine_java_autoscale](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting) | resource | +| [azurerm_monitor_autoscale_setting.autoscale_app_service_printit_pdf_engine_java_autoscale_clone](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting) | resource | | [azurerm_monitor_scheduled_query_rules_alert.generate-pdf-engine-generate-responsetime](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert) | resource | | [azurerm_monitor_scheduled_query_rules_alert.pagopa-pdf-engine-pdf-availability](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert) | resource | | [azurerm_monitor_scheduled_query_rules_alert.pagopa-print-payment-notice-generator-responsetime-upd](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert) | resource | @@ -200,6 +206,7 @@ No outputs. | [azurerm_monitor_scheduled_query_rules_alert.print-notice-retry-fn-error-alert](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert) | resource | | [azurerm_private_dns_a_record.ingress](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_a_record) | resource | | [azurerm_resource_group.printit_pdf_engine_app_service_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource | +| [azurerm_resource_group.printit_pdf_engine_app_service_rg_clone](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource | | [helm_release.cert_mounter](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [helm_release.reloader](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [kubernetes_namespace.namespace](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource | @@ -255,7 +262,7 @@ No outputs. | [ingress\_load\_balancer\_ip](#input\_ingress\_load\_balancer\_ip) | ## Aks | `string` | n/a | yes | | [instance](#input\_instance) | One of beta, prod01, prod02 | `string` | n/a | yes | | [io\_backend\_base\_path](#input\_io\_backend\_base\_path) | io backend api base path | `string` | `null` | no | -| [is\_feature\_enabled](#input\_is\_feature\_enabled) | n/a |
object({
pdf_engine = bool
printit = bool
})
|
{
"pdf_engine": false,
"printit": false
}
| no | +| [is\_feature\_enabled](#input\_is\_feature\_enabled) | n/a |
object({
pdf_engine = bool
printit = bool
apim_use_pdf_engine_clone = optional(bool, false)
pdf_engine_clone = optional(bool, false)
})
|
{
"apim_use_pdf_engine_clone": false,
"pdf_engine": false,
"pdf_engine_clone": false,
"printit": false
}
| no | | [k8s\_kube\_config\_path\_prefix](#input\_k8s\_kube\_config\_path\_prefix) | n/a | `string` | `"~/.kube"` | no | | [location](#input\_location) | One of westeurope, northeurope | `string` | n/a | yes | | [location\_short](#input\_location\_short) | One of wue, neu | `string` | n/a | yes | diff --git a/src/domains/printit-app/env/itn-prod/terraform.tfvars b/src/domains/printit-app/env/itn-prod/terraform.tfvars index 3bd0c7b6a..b5915fee1 100644 --- a/src/domains/printit-app/env/itn-prod/terraform.tfvars +++ b/src/domains/printit-app/env/itn-prod/terraform.tfvars @@ -37,8 +37,10 @@ ingress_load_balancer_ip = "10.3.2.250" # pdf-engine is_feature_enabled = { - pdf_engine = true - printit = true + pdf_engine = true + pdf_engine_clone = true + printit = true + apim_use_pdf_engine_clone = false } app_service_pdf_engine_sku_name = "P2v3" diff --git a/src/domains/shared-app/01_app_service_pdf_engine.tf b/src/domains/shared-app/01_app_service_pdf_engine.tf index bc42d95a0..d5d02d01d 100644 --- a/src/domains/shared-app/01_app_service_pdf_engine.tf +++ b/src/domains/shared-app/01_app_service_pdf_engine.tf @@ -21,7 +21,7 @@ moved { resource "azurerm_resource_group" "shared_pdf_engine_app_service_rg" { - count = var.env_short != "p" ? 1 : 0 # only DEV and UAT + count = 1 name = format("%s-pdf-engine-rg", local.project) location = var.location @@ -38,7 +38,7 @@ data "azurerm_container_registry" "container_registry" { ################ module "shared_pdf_engine_app_service" { - count = var.env_short != "p" ? 1 : 0 # only DEV and UAT + count = 1 source = "./.terraform/modules/__v3__/app_service" vnet_integration = false @@ -72,7 +72,7 @@ module "shared_pdf_engine_app_service" { } module "shared_pdf_engine_slot_staging" { - count = var.env_short == "u" ? 1 : 0 + count = var.env_short != "d" ? 1 : 0 source = "./.terraform/modules/__v3__/app_service_slot" @@ -102,7 +102,7 @@ module "shared_pdf_engine_slot_staging" { } resource "azurerm_monitor_autoscale_setting" "autoscale_app_service_shared_pdf_engine_autoscale" { - count = var.env_short == "u" ? 1 : 0 + count = var.env_short != "d" ? 1 : 0 name = format("%s-autoscale-pdf-engine", local.project) resource_group_name = azurerm_resource_group.shared_pdf_engine_app_service_rg[0].name @@ -114,9 +114,9 @@ resource "azurerm_monitor_autoscale_setting" "autoscale_app_service_shared_pdf_e name = "default" capacity { - default = 1 - minimum = 1 - maximum = 1 + default = var.env_short == "p" ? 3 : 1 + minimum = var.env_short == "p" ? 3 : 1 + maximum = var.env_short == "p" ? 12 : 1 } # Requests @@ -270,7 +270,7 @@ resource "azurerm_monitor_autoscale_setting" "autoscale_app_service_shared_pdf_e ################ module "shared_pdf_engine_app_service_java" { source = "./.terraform/modules/__v3__/app_service" - count = var.env_short != "p" ? 1 : 0 # only DEV and UAT + count = 1 vnet_integration = false resource_group_name = azurerm_resource_group.shared_pdf_engine_app_service_rg[0].name location = var.location @@ -302,7 +302,7 @@ module "shared_pdf_engine_app_service_java" { } module "shared_pdf_engine_java_slot_staging" { - count = var.env_short == "u" ? 1 : 0 + count = var.env_short != "d" ? 1 : 0 source = "./.terraform/modules/__v3__/app_service_slot" @@ -334,7 +334,7 @@ module "shared_pdf_engine_java_slot_staging" { } resource "azurerm_monitor_autoscale_setting" "autoscale_app_service_shared_pdf_engine_java_autoscale" { - count = var.env_short == "u" ? 1 : 0 + count = var.env_short != "d" ? 1 : 0 name = format("%s-autoscale-pdf-engine-java", local.project) resource_group_name = azurerm_resource_group.shared_pdf_engine_app_service_rg[0].name diff --git a/src/domains/shared-app/04_apim_pdf_engine.tf b/src/domains/shared-app/04_apim_pdf_engine.tf index d63397912..3dc81dc9e 100644 --- a/src/domains/shared-app/04_apim_pdf_engine.tf +++ b/src/domains/shared-app/04_apim_pdf_engine.tf @@ -29,14 +29,14 @@ locals { description = "PDF Engine Service pagoPA - API" path = "shared/pdf-engine" subscription_required = true - service_url = var.pdf_engine_app_ha_enabled ? module.shared_pdf_engine_app_service_java_ha[0].default_site_hostname : module.shared_pdf_engine_app_service_java[0].default_site_hostname + service_url = var.apim_use_pdf_engine_app_ha ? module.shared_pdf_engine_app_service_java_ha[0].default_site_hostname : module.shared_pdf_engine_app_service_java[0].default_site_hostname } apim_pdf_engine_node_service_api = { # node display_name = "PDF Engine Node Service pagoPA - API" description = "PDF Engine Node Service pagoPA - API" path = "shared/pdf-engine-node" subscription_required = true - service_url = var.pdf_engine_app_ha_enabled ? module.shared_pdf_engine_app_service_ha[0].default_site_hostname : module.shared_pdf_engine_app_service[0].default_site_hostname + service_url = var.apim_use_pdf_engine_app_ha ? module.shared_pdf_engine_app_service_ha[0].default_site_hostname : module.shared_pdf_engine_app_service[0].default_site_hostname } } diff --git a/src/domains/shared-app/99_variables.tf b/src/domains/shared-app/99_variables.tf index 1a00929ef..d1c5a748c 100644 --- a/src/domains/shared-app/99_variables.tf +++ b/src/domains/shared-app/99_variables.tf @@ -305,6 +305,12 @@ variable "pdf_engine_app_ha_enabled" { description = "(Required) enables the deployment of pdf engine in HA mode" } +variable "apim_use_pdf_engine_app_ha" { + type = bool + description = "(Optional) enables the usage of pdf engine in HA mode" + default = false +} + // wallet session token variable "io_backend_base_path" { type = string diff --git a/src/domains/shared-app/README.md b/src/domains/shared-app/README.md index 2c2f625e8..e1cfb2b61 100644 --- a/src/domains/shared-app/README.md +++ b/src/domains/shared-app/README.md @@ -163,6 +163,7 @@ | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [apim\_dns\_zone\_prefix](#input\_apim\_dns\_zone\_prefix) | The dns subdomain for apim. | `string` | `null` | no | +| [apim\_use\_pdf\_engine\_app\_ha](#input\_apim\_use\_pdf\_engine\_app\_ha) | (Optional) enables the usage of pdf engine in HA mode | `bool` | `false` | no | | [app\_service\_pdf\_engine\_always\_on](#input\_app\_service\_pdf\_engine\_always\_on) | Always on property | `bool` | `true` | no | | [app\_service\_pdf\_engine\_autoscale\_enabled](#input\_app\_service\_pdf\_engine\_autoscale\_enabled) | n/a | `bool` | `true` | no | | [app\_service\_pdf\_engine\_sku\_name](#input\_app\_service\_pdf\_engine\_sku\_name) | app service plan size | `string` | `"S1"` | no | diff --git a/src/domains/shared-app/env/weu-prod/terraform.tfvars b/src/domains/shared-app/env/weu-prod/terraform.tfvars index ecba144dd..1010386a0 100644 --- a/src/domains/shared-app/env/weu-prod/terraform.tfvars +++ b/src/domains/shared-app/env/weu-prod/terraform.tfvars @@ -92,6 +92,7 @@ pagopa_shared_toolbox_enabled = false robots_indexed_paths = [] pdf_engine_app_ha_enabled = true pdf_engine_zone_balancing_enabled = true +apim_use_pdf_engine_app_ha = true // wallet session token io_backend_base_path = "https://api-app.io.pagopa.it"