From c9413e43d5c153e53e5273458dbdbea8c8199e2b Mon Sep 17 00:00:00 2001 From: Mario Mupo <43968294+mamu0@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:50:37 +0200 Subject: [PATCH] Deleted io-p-messages-sending-func (#1181) --- .../12_function_service_messages.tf | 441 ------------------ src/domains/messages-app/README.md | 9 - 2 files changed, 450 deletions(-) delete mode 100644 src/domains/messages-app/12_function_service_messages.tf diff --git a/src/domains/messages-app/12_function_service_messages.tf b/src/domains/messages-app/12_function_service_messages.tf deleted file mode 100644 index fe1677da2..000000000 --- a/src/domains/messages-app/12_function_service_messages.tf +++ /dev/null @@ -1,441 +0,0 @@ -resource "azurerm_resource_group" "service_messages_rg" { - name = format("%s-service-messages-rg", local.product) - location = var.location - tags = var.tags -} - -data "azurerm_storage_account" "services_storage" { - name = "iopmessagesweuprod01svst" - resource_group_name = "io-p-messages-weu-prod01-data-process-rg" -} - -data "azurerm_key_vault_secret" "appbackendli_token" { - name = "appbackendli-token" - key_vault_id = data.azurerm_key_vault.kv.id -} - -data "azurerm_key_vault_secret" "internal_user" { - name = "internal-user-id-to-skip" - key_vault_id = data.azurerm_key_vault.kv.id -} - -data "azurerm_subnet" "runner_subnet" { - name = "${local.product}-github-runner-snet" - virtual_network_name = local.vnet_common_name - resource_group_name = local.vnet_common_resource_group_name -} - -locals { - function_service_messages = { - app_settings = { - FUNCTIONS_WORKER_RUNTIME = "node" - WEBSITE_RUN_FROM_PACKAGE = "1" - WEBSITE_DNS_SERVER = "168.63.129.16" - FUNCTIONS_WORKER_PROCESS_COUNT = 4 - NODE_ENV = "production" - - APPINSIGHTS_INSTRUMENTATIONKEY = data.azurerm_application_insights.application_insights.instrumentation_key - MESSAGE_CONTENT_STORAGE_CONNECTION_STRING = data.azurerm_storage_account.storage_api.primary_connection_string - - BACKEND_BASE_URL = "https://io-p-app-appbackendli.azurewebsites.net" - BACKEND_TOKEN = data.azurerm_key_vault_secret.appbackendli_token.value - - QueueStorageConnection = data.azurerm_storage_account.services_storage.primary_connection_string - NOTIFICATION_QUEUE_STORAGE_CONNECTION_STRING = data.azurerm_storage_account.push_notifications_storage.primary_connection_string - NOTIFICATION_QUEUE_NAME = "push-notifications" - - COSMOSDB_NAME = "db" - COSMOSDB_URI = data.azurerm_cosmosdb_account.cosmos_api.endpoint - COSMOSDB_KEY = data.azurerm_cosmosdb_account.cosmos_api.primary_key - COSMOSDB_CONNECTION_STRING = format("AccountEndpoint=%s;AccountKey=%s;", data.azurerm_cosmosdb_account.cosmos_api.endpoint, data.azurerm_cosmosdb_account.cosmos_api.primary_key) - - MESSAGE_CONTAINER_NAME = "message-content" - - REMOTE_CONTENT_COSMOSDB_URI = data.azurerm_cosmosdb_account.cosmos_remote_content.endpoint - REMOTE_CONTENT_COSMOSDB_KEY = data.azurerm_cosmosdb_account.cosmos_remote_content.primary_key - REMOTE_CONTENT_COSMOSDB_NAME = "remote-content" - REMOTE_CONTENT_COSMOSDB_CONNECTION_STRING = format("AccountEndpoint=%s;AccountKey=%s;", data.azurerm_cosmosdb_account.cosmos_remote_content.endpoint, data.azurerm_cosmosdb_account.cosmos_remote_content.primary_key) - - MESSAGE_CONFIGURATION_CHANGE_FEED_LEASE_PREFIX = "RemoteContentMessageConfigurationChangeFeed-00" - MESSAGE_CONFIGURATION_CHANGE_FEED_START_TIME = "0" - - // REDIS - REDIS_URL = data.azurerm_redis_cache.redis_messages.hostname - REDIS_PORT = data.azurerm_redis_cache.redis_messages.ssl_port - REDIS_PASSWORD = data.azurerm_redis_cache.redis_messages.primary_access_key - - INTERNAL_USER_ID = data.azurerm_key_vault_secret.internal_user.value - RC_CONFIGURATION_CACHE_TTL = "28800" - - // Keepalive fields are all optionals - FETCH_KEEPALIVE_ENABLED = "true" - FETCH_KEEPALIVE_SOCKET_ACTIVE_TTL = "110000" - FETCH_KEEPALIVE_MAX_SOCKETS = "40" - FETCH_KEEPALIVE_MAX_FREE_SOCKETS = "10" - FETCH_KEEPALIVE_FREE_SOCKET_TIMEOUT = "30000" - FETCH_KEEPALIVE_TIMEOUT = "60000" - } - } -} - -module "function_service_messages_snet" { - source = "github.com/pagopa/terraform-azurerm-v3//subnet?ref=v8.27.0" - - name = format("%s-fn-service-messages-snet", local.product) - address_prefixes = var.cidr_subnet_fnservicemessages - resource_group_name = data.azurerm_virtual_network.vnet_common.resource_group_name - virtual_network_name = data.azurerm_virtual_network.vnet_common.name - private_endpoint_network_policies_enabled = false - - service_endpoints = [ - "Microsoft.Web", - "Microsoft.AzureCosmosDB", - "Microsoft.Storage", - ] - - delegation = { - name = "default" - service_delegation = { - name = "Microsoft.Web/serverFarms" - actions = ["Microsoft.Network/virtualNetworks/subnets/action"] - } - } -} - -module "function_service_messages" { - count = var.function_service_messages_enabled ? 1 : 0 - source = "github.com/pagopa/terraform-azurerm-v3//function_app?ref=v8.27.0" - - resource_group_name = azurerm_resource_group.service_messages_rg.name - name = format("%s-messages-sending-func", local.product) - location = azurerm_resource_group.service_messages_rg.location - domain = "MESSAGES" - - health_check_path = "/api/v1/info" - health_check_maxpingfailures = 2 - - node_version = "18" - runtime_version = "~4" - always_on = true - application_insights_instrumentation_key = data.azurerm_application_insights.application_insights.instrumentation_key - - app_service_plan_info = { - kind = "Linux" - sku_tier = "PremiumV3" - sku_size = "P1v3" - maximum_elastic_worker_count = 0 - worker_count = null - zone_balancing_enabled = false - } - - storage_account_info = { - account_kind = "StorageV2" - account_tier = "Standard" - account_replication_type = "GZRS" - access_tier = "Hot" - advanced_threat_protection_enable = true - use_legacy_defender_version = true - public_network_access_enabled = false - } - - app_settings = merge( - local.function_service_messages.app_settings, - ) - - subnet_id = module.function_service_messages_snet.id - - allowed_subnets = [ - module.function_service_messages_snet.id, - data.azurerm_subnet.apim_snet.id, - ] - - allowed_ips = concat( - [], - local.app_insights_ips_west_europe, - ) - - action = [ - { - action_group_id = data.azurerm_monitor_action_group.error_action_group.id - webhook_properties = null - } - ] - - client_certificate_mode = "Required" - - tags = var.tags -} - -module "function_service_messages_staging_slot" { - count = var.function_service_messages_enabled ? 1 : 0 - source = "github.com/pagopa/terraform-azurerm-v3//function_app_slot?ref=v8.27.0" - - name = "staging" - location = var.location - resource_group_name = azurerm_resource_group.service_messages_rg.name - function_app_id = module.function_service_messages[0].id - app_service_plan_id = module.function_service_messages[0].app_service_plan_id - - health_check_path = "/api/v1/info" - health_check_maxpingfailures = 2 - - node_version = "18" - runtime_version = "~4" - always_on = true - application_insights_instrumentation_key = data.azurerm_application_insights.application_insights.instrumentation_key - - storage_account_name = module.function_service_messages[0].storage_account.name - storage_account_access_key = module.function_service_messages[0].storage_account.primary_access_key - - app_settings = merge( - local.function_service_messages.app_settings, - ) - - subnet_id = module.function_service_messages_snet.id - - allowed_subnets = [ - module.function_service_messages_snet.id, - data.azurerm_subnet.azdoa_snet.id, - data.azurerm_subnet.runner_subnet.id - ] - - allowed_ips = concat( - [], - ) - - tags = var.tags -} - -resource "azurerm_monitor_autoscale_setting" "function_service_messages" { - count = var.function_service_messages_enabled ? 1 : 0 - name = replace(module.function_service_messages[0].name, "fn", "as") - resource_group_name = azurerm_resource_group.service_messages_rg.name - location = var.location - target_resource_id = module.function_service_messages[0].app_service_plan_id - - profile { - name = "{\"name\":\"default\",\"for\":\"evening\"}" - - recurrence { - hours = [22] - minutes = [59] - timezone = "W. Europe Standard Time" - days = [ - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - "Sunday" - ] - } - - capacity { - default = 10 - minimum = 2 - maximum = 30 - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_service_messages[0].id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Max" - time_window = "PT1M" - time_aggregation = "Maximum" - operator = "GreaterThan" - threshold = 3000 - divide_by_instance_count = true - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "2" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_service_messages[0].app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Max" - time_window = "PT1M" - time_aggregation = "Maximum" - operator = "GreaterThan" - threshold = 40 - divide_by_instance_count = false - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "3" - cooldown = "PT2M" - } - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_service_messages[0].id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 300 - divide_by_instance_count = true - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_service_messages[0].app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 15 - divide_by_instance_count = false - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT1M" - } - } - } - - profile { - name = "evening" - - recurrence { - hours = [19] - minutes = [30] - timezone = "W. Europe Standard Time" - days = [ - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - "Sunday" - ] - } - - capacity { - default = 10 - minimum = 4 - maximum = 30 - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_service_messages[0].id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Max" - time_window = "PT1M" - time_aggregation = "Maximum" - operator = "GreaterThan" - threshold = 2500 - divide_by_instance_count = true - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "2" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_service_messages[0].app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Max" - time_window = "PT1M" - time_aggregation = "Maximum" - operator = "GreaterThan" - threshold = 40 - divide_by_instance_count = false - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "3" - cooldown = "PT2M" - } - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_service_messages[0].id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 200 - divide_by_instance_count = true - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_service_messages[0].app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 10 - divide_by_instance_count = false - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT1M" - } - } - } -} diff --git a/src/domains/messages-app/README.md b/src/domains/messages-app/README.md index ff7ffc966..1da920d93 100644 --- a/src/domains/messages-app/README.md +++ b/src/domains/messages-app/README.md @@ -21,9 +21,6 @@ | [function\_messages\_cqrs](#module\_function\_messages\_cqrs) | github.com/pagopa/terraform-azurerm-v3//function_app | v8.27.0 | | [function\_messages\_cqrs\_snet](#module\_function\_messages\_cqrs\_snet) | github.com/pagopa/terraform-azurerm-v3//subnet | v8.27.0 | | [function\_messages\_cqrs\_staging\_slot](#module\_function\_messages\_cqrs\_staging\_slot) | github.com/pagopa/terraform-azurerm-v3//function_app_slot | v8.27.0 | -| [function\_service\_messages](#module\_function\_service\_messages) | github.com/pagopa/terraform-azurerm-v3//function_app | v8.27.0 | -| [function\_service\_messages\_snet](#module\_function\_service\_messages\_snet) | github.com/pagopa/terraform-azurerm-v3//subnet | v8.27.0 | -| [function\_service\_messages\_staging\_slot](#module\_function\_service\_messages\_staging\_slot) | github.com/pagopa/terraform-azurerm-v3//function_app_slot | v8.27.0 | | [pod\_identity](#module\_pod\_identity) | github.com/pagopa/terraform-azurerm-v3//kubernetes_pod_identity | v8.27.0 | | [push\_notif\_function](#module\_push\_notif\_function) | github.com/pagopa/terraform-azurerm-v3//function_app | v8.27.0 | | [push\_notif\_function\_staging\_slot](#module\_push\_notif\_function\_staging\_slot) | github.com/pagopa/terraform-azurerm-v3//function_app_slot | v8.27.0 | @@ -42,7 +39,6 @@ | [azurerm_key_vault_secret.services_storage_connection_string](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) | resource | | [azurerm_monitor_autoscale_setting.app_messages_function](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting) | resource | | [azurerm_monitor_autoscale_setting.function_messages_cqrs](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting) | resource | -| [azurerm_monitor_autoscale_setting.function_service_messages](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting) | resource | | [azurerm_monitor_autoscale_setting.push_notif_function](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting) | resource | | [azurerm_monitor_metric_alert.tls_cert_check](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_metric_alert) | resource | | [azurerm_private_dns_a_record.ingress](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_a_record) | resource | @@ -52,7 +48,6 @@ | [azurerm_resource_group.data_process_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource | | [azurerm_resource_group.event_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource | | [azurerm_resource_group.push_notif_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource | -| [azurerm_resource_group.service_messages_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource | | [azurerm_storage_container.services_storage_messages](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_container) | resource | | [azurerm_storage_management_policy.services_storage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_management_policy) | resource | | [helm_release.cert-mounter](https://registry.terraform.io/providers/hashicorp/helm/2.8.0/docs/resources/release) | resource | @@ -79,14 +74,12 @@ | [azurerm_key_vault.kv](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault) | data source | | [azurerm_key_vault.kv_common](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault) | data source | | [azurerm_key_vault_secret.apim_services_subscription_key](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source | -| [azurerm_key_vault_secret.appbackendli_token](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source | | [azurerm_key_vault_secret.azure_nh_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source | | [azurerm_key_vault_secret.azure_nh_partition1_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source | | [azurerm_key_vault_secret.azure_nh_partition2_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source | | [azurerm_key_vault_secret.azure_nh_partition3_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source | | [azurerm_key_vault_secret.azure_nh_partition4_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source | | [azurerm_key_vault_secret.fn_messages_APP_MESSAGES_BETA_FISCAL_CODES](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source | -| [azurerm_key_vault_secret.internal_user](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source | | [azurerm_kubernetes_cluster.aks](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_cluster) | data source | | [azurerm_log_analytics_workspace.log_analytics](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/log_analytics_workspace) | data source | | [azurerm_monitor_action_group.email](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/monitor_action_group) | data source | @@ -106,14 +99,12 @@ | [azurerm_resource_group.notifications_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source | | [azurerm_storage_account.push_notif_beta_storage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source | | [azurerm_storage_account.push_notifications_storage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source | -| [azurerm_storage_account.services_storage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source | | [azurerm_storage_account.storage_api](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account) | data source | | [azurerm_subnet.apim_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source | | [azurerm_subnet.app_backendl1_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source | | [azurerm_subnet.app_backendl2_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source | | [azurerm_subnet.azdoa_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source | | [azurerm_subnet.private_endpoints_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source | -| [azurerm_subnet.runner_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source | | [azurerm_subscription.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subscription) | data source | | [azurerm_virtual_network.vnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source | | [azurerm_virtual_network.vnet_common](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source |