Skip to content

Conversation

christian-calabrese
Copy link
Contributor

@christian-calabrese christian-calabrese commented Dec 10, 2024

Motivation and Context

Reduce costs

Major Changes

Reduced sku, removed autoscaler and slot for eucovidcert function

Dependencies

Testing

Documentation

Other Considerations

@christian-calabrese christian-calabrese requested review from a team as code owners December 10, 2024 16:29
@christian-calabrese christian-calabrese changed the title [CES-509] Reduced sku, removed autoscaler, staging slot and of eucovidcer… [CES-509] Reduced sku, removed autoscaler and slot for eucovidcert function Dec 10, 2024
Copy link

github-actions bot commented Dec 10, 2024

Terraform Plan ('src/domains/eucovidcert/prod/westeurope') 📖

Terraform Plan
module.function_apps.data.azurerm_linux_function_app.function_services[1]: Still reading... [10s elapsed]
module.function_apps.data.azurerm_linux_function_app.function_services[0]: Still reading... [10s elapsed]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
  - destroy

Terraform will perform the following actions:

  # module.function_apps.azurerm_monitor_autoscale_setting.function_eucovidcert will be destroyed
  # (because azurerm_monitor_autoscale_setting.function_eucovidcert is not in configuration)
  - resource "azurerm_monitor_autoscale_setting" "function_eucovidcert" {
      - enabled             = true -> null
      - id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Insights/autoScaleSettings/io-p-eucovidcert-fn-autoscale" -> null
      - location            = "westeurope" -> null
      - name                = "io-p-eucovidcert-fn-autoscale" -> null
      - resource_group_name = "io-p-rg-eucovidcert" -> null
      - tags                = {
          - "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
          - "CreatedBy"      = "Terraform"
          - "Environment"    = "Prod"
          - "ManagementTeam" = "IO Wallet"
          - "Owner"          = "IO"
          - "Source"         = "https://github.com/pagopa/io-infra/blob/main/src/domains/eucovidcert/prod/westeurope"
        } -> null
      - target_resource_id  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/serverFarms/io-p-eucovidcert-fn-plan" -> null

      - profile {
          - name = "default" -> null

          - capacity {
              - default = 10 -> null
              - maximum = 20 -> null
              - minimum = 1 -> null
            }

          - rule {
              - metric_trigger {
                  - divide_by_instance_count = false -> null
                  - metric_name              = "Requests" -> null
                  - metric_namespace         = "microsoft.web/sites" -> null
                  - metric_resource_id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/sites/io-p-eucovidcert-fn" -> null
                  - operator                 = "GreaterThan" -> null
                  - statistic                = "Average" -> null
                  - threshold                = 3000 -> null
                  - time_aggregation         = "Average" -> null
                  - time_grain               = "PT1M" -> null
                  - time_window              = "PT5M" -> null
                }
              - scale_action {
                  - cooldown  = "PT5M" -> null
                  - direction = "Increase" -> null
                  - type      = "ChangeCount" -> null
                  - value     = 2 -> null
                }
            }
          - rule {
              - metric_trigger {
                  - divide_by_instance_count = false -> null
                  - metric_name              = "CpuPercentage" -> null
                  - metric_namespace         = "microsoft.web/serverfarms" -> null
                  - metric_resource_id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/serverFarms/io-p-eucovidcert-fn-plan" -> null
                  - operator                 = "GreaterThan" -> null
                  - statistic                = "Average" -> null
                  - threshold                = 45 -> null
                  - time_aggregation         = "Average" -> null
                  - time_grain               = "PT1M" -> null
                  - time_window              = "PT5M" -> null
                }
              - scale_action {
                  - cooldown  = "PT5M" -> null
                  - direction = "Increase" -> null
                  - type      = "ChangeCount" -> null
                  - value     = 2 -> null
                }
            }
          - rule {
              - metric_trigger {
                  - divide_by_instance_count = false -> null
                  - metric_name              = "Requests" -> null
                  - metric_namespace         = "microsoft.web/sites" -> null
                  - metric_resource_id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/sites/io-p-eucovidcert-fn" -> null
                  - operator                 = "LessThan" -> null
                  - statistic                = "Average" -> null
                  - threshold                = 2000 -> null
                  - time_aggregation         = "Average" -> null
                  - time_grain               = "PT1M" -> null
                  - time_window              = "PT5M" -> null
                }
              - scale_action {
                  - cooldown  = "PT20M" -> null
                  - direction = "Decrease" -> null
                  - type      = "ChangeCount" -> null
                  - value     = 1 -> null
                }
            }
          - rule {
              - metric_trigger {
                  - divide_by_instance_count = false -> null
                  - metric_name              = "CpuPercentage" -> null
                  - metric_namespace         = "microsoft.web/serverfarms" -> null
                  - metric_resource_id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/serverFarms/io-p-eucovidcert-fn-plan" -> null
                  - operator                 = "LessThan" -> null
                  - statistic                = "Average" -> null
                  - threshold                = 30 -> null
                  - time_aggregation         = "Average" -> null
                  - time_grain               = "PT1M" -> null
                  - time_window              = "PT5M" -> null
                }
              - scale_action {
                  - cooldown  = "PT20M" -> null
                  - direction = "Decrease" -> null
                  - type      = "ChangeCount" -> null
                  - value     = 1 -> null
                }
            }
        }
    }

  # module.function_apps.module.function_eucovidcert.azurerm_service_plan.this[0] will be updated in-place
  ~ resource "azurerm_service_plan" "this" {
        id                           = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/serverFarms/io-p-eucovidcert-fn-plan"
        name                         = "io-p-eucovidcert-fn-plan"
      ~ sku_name                     = "P1v3" -> "B1"
        tags                         = {
            "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"      = "Terraform"
            "Environment"    = "Prod"
            "ManagementTeam" = "IO Wallet"
            "Owner"          = "IO"
            "Source"         = "https://github.com/pagopa/io-infra/blob/main/src/domains/eucovidcert/prod/westeurope"
        }
        # (10 unchanged attributes hidden)

      - timeouts {}
    }

  # module.function_apps.module.function_eucovidcert_staging_slot.azurerm_app_service_slot_virtual_network_swift_connection.this[0] will be destroyed
  # (because azurerm_app_service_slot_virtual_network_swift_connection.this is not in configuration)
  - resource "azurerm_app_service_slot_virtual_network_swift_connection" "this" {
      - app_service_id = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/sites/io-p-eucovidcert-fn" -> null
      - id             = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/sites/io-p-eucovidcert-fn/slots/staging/config/virtualNetwork" -> null
      - slot_name      = "staging" -> null
      - subnet_id      = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.Network/virtualNetworks/io-p-vnet-common/subnets/io-p-eucovidcert-snet" -> null
    }

  # module.function_apps.module.function_eucovidcert_staging_slot.azurerm_linux_function_app_slot.this will be destroyed
  # (because azurerm_linux_function_app_slot.this is not in configuration)
  - resource "azurerm_linux_function_app_slot" "this" {
      - app_settings                                   = {
          - "APPINSIGHTS_SAMPLING_PERCENTAGE"                 = "5"
          - "AzureWebJobs.NotifyNewProfileToDGC.Disabled"     = "1"
          - "DGC_LOAD_TEST_CLIENT_CERT"                       = (sensitive value)
          - "DGC_LOAD_TEST_CLIENT_KEY"                        = (sensitive value)
          - "DGC_LOAD_TEST_SERVER_CA"                         = (sensitive value)
          - "DGC_LOAD_TEST_URL"                               = "https://io-p-fn3-mockdgc.azurewebsites.net"
          - "DGC_PROD_CLIENT_CERT"                            = (sensitive value)
          - "DGC_PROD_CLIENT_KEY"                             = (sensitive value)
          - "DGC_PROD_SERVER_CA"                              = (sensitive value)
          - "DGC_PROD_URL"                                    = "https://servizi-pn.dgc.gov.it"
          - "DGC_UAT_CLIENT_CERT"                             = (sensitive value)
          - "DGC_UAT_CLIENT_KEY"                              = (sensitive value)
          - "DGC_UAT_FISCAL_CODES"                            = "PRVPRV25A01H501B,XXXXXP25A01H501L,YYYYYP25A01H501K,KKKKKP25A01H501U,QQQQQP25A01H501S,WWWWWP25A01H501A,ZZZZZP25A01H501J,JJJJJP25A01H501X,GGGGGP25A01H501Z"
          - "DGC_UAT_SERVER_CA"                               = (sensitive value)
          - "DGC_UAT_URL"                                     = "https://servizi-pnval.dgc.gov.it"
          - "EUCOVIDCERT_NOTIFY_NEW_PROFILE_QUEUE_NAME"       = "notify-new-profile"
          - "EUCOVIDCERT_PROFILE_CREATED_QUEUE_NAME"          = "eucovidcert-profile-created"
          - "EUCOVIDCERT_TRACE_NOTIFY_NEW_PROFILE_TABLE_NAME" = "TraceNotifyNewProfile"
          - "EventsQueueStorageConnection"                    = (sensitive value)
          - "FETCH_KEEPALIVE_ENABLED"                         = "true"
          - "FETCH_KEEPALIVE_FREE_SOCKET_TIMEOUT"             = "30000"
          - "FETCH_KEEPALIVE_MAX_FREE_SOCKETS"                = "10"
          - "FETCH_KEEPALIVE_MAX_SOCKETS"                     = "40"
          - "FETCH_KEEPALIVE_SOCKET_ACTIVE_TTL"               = "110000"
          - "FETCH_KEEPALIVE_TIMEOUT"                         = "60000"
          - "FNSERVICES_API_KEY"                              = (sensitive value)
          - "FNSERVICES_API_URL"                              = "https://io-p-services-fn-1.azurewebsites.net/api/v1,https://io-p-services-fn-2.azurewebsites.net/api/v1"
          - "FUNCTIONS_WORKER_PROCESS_COUNT"                  = "4"
          - "FUNCTIONS_WORKER_RUNTIME"                        = "node"
          - "LOAD_TEST_FISCAL_CODES"                          = "AAAAAA00A00A000B,AAAAAA00A00A000C,AAAAAA00A00A000D,AAAAAA00A00A000E"
          - "NODE_ENV"                                        = "production"
          - "QueueStorageConnection"                          = (sensitive value)
          - "SLOT_TASK_HUBNAME"                               = "StagingTaskHub"
          - "TableStorageConnection"                          = (sensitive value)
          - "WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG" = "1"
          - "WEBSITE_DNS_SERVER"                              = "168.63.129.16"
          - "WEBSITE_RUN_FROM_PACKAGE"                        = "1"
        } -> null
      - builtin_logging_enabled                        = false -> null
      - client_certificate_enabled                     = false -> null
      - client_certificate_mode                        = "Optional" -> null
      - content_share_force_disabled                   = false -> null
      - custom_domain_verification_id                  = (sensitive value) -> null
      - daily_memory_time_quota                        = 0 -> null
      - default_hostname                               = "io-p-eucovidcert-fn-staging.azurewebsites.net" -> null
      - enabled                                        = true -> null
      - ftp_publish_basic_authentication_enabled       = true -> null
      - function_app_id                                = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/sites/io-p-eucovidcert-fn" -> null
      - functions_extension_version                    = "~4" -> null
      - https_only                                     = true -> null
      - id                                             = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-eucovidcert/providers/Microsoft.Web/sites/io-p-eucovidcert-fn/slots/staging" -> null
      - key_vault_reference_identity_id                = "SystemAssigned" -> null
      - kind                                           = "functionapp,linux" -> null
      - name                                           = "staging" -> null
      - outbound_ip_address_list                       = [] -> null
      - possible_outbound_ip_address_list              = [] -> null
      - public_network_access_enabled                  = true -> null
      - site_credential                                = (sensitive value) -> null
      - storage_account_access_key                     = (sensitive value) -> null
      - storage_account_name                           = "iopeucovidcertfnst" -> null
      - storage_uses_managed_identity                  = false -> null
      - tags                                           = {
          - "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
          - "CreatedBy"      = "Terraform"
          - "Environment"    = "Prod"
          - "ManagementTeam" = "IO Wallet"
          - "Owner"          = "IO"
          - "Source"         = "https://github.com/pagopa/io-infra/blob/main/src/domains/eucovidcert/prod/westeurope"
        } -> null
      - virtual_network_subnet_id                      = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.Network/virtualNetworks/io-p-vnet-common/subnets/io-p-eucovidcert-snet" -> null
      - webdeploy_publish_basic_authentication_enabled = true -> null
        # (6 unchanged attributes hidden)

      - site_config {
          - always_on                                     = true -> null
          - app_scale_limit                               = 0 -> null
          - application_insights_key                      = (sensitive value) -> null
          - container_registry_use_managed_identity       = false -> null
          - default_documents                             = [
              - "Default.htm",
              - "Default.html",
              - "Default.asp",
              - "index.htm",
              - "index.html",
              - "iisstart.htm",
              - "default.aspx",
              - "index.php",
            ] -> null
          - detailed_error_logging_enabled                = false -> null
          - elastic_instance_minimum                      = 1 -> null
          - ftps_state                                    = "Disabled" -> null
          - health_check_eviction_time_in_min             = 10 -> null
          - health_check_path                             = "/api/v1/info" -> null
          - http2_enabled                                 = true -> null
          - linux_fx_version                              = "NODE|14" -> null
          - load_balancing_mode                           = "LeastRequests" -> null
          - managed_pipeline_mode                         = "Integrated" -> null
          - minimum_tls_version                           = "1.2" -> null
          - pre_warmed_instance_count                     = 1 -> null
          - remote_debugging_enabled                      = false -> null
          - runtime_scale_monitoring_enabled              = false -> null
          - scm_minimum_tls_version                       = "1.2" -> null
          - scm_type                                      = "VSTSRM" -> null
          - scm_use_main_ip_restriction                   = false -> null
          - use_32_bit_worker                             = false -> null
          - vnet_route_all_enabled                        = true -> null
          - websockets_enabled                            = false -> null
          - worker_count                                  = 1 -> null
            # (7 unchanged attributes hidden)

          - application_stack {
              - node_version                = "14" -> null
              - use_custom_runtime          = false -> null
              - use_dotnet_isolated_runtime = false -> null
                # (4 unchanged attributes hidden)
            }

          - ip_restriction {
              - action                    = "Allow" -> null
              - headers                   = [] -> null
              - name                      = "rule" -> null
              - priority                  = 65000 -> null
              - virtual_network_subnet_id = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.Network/virtualNetworks/io-p-vnet-common/subnets/azure-devops" -> null
                # (2 unchanged attributes hidden)
            }
          - ip_restriction {
              - action                    = "Allow" -> null
              - headers                   = [] -> null
              - name                      = "rule" -> null
              - priority                  = 65000 -> null
              - virtual_network_subnet_id = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.Network/virtualNetworks/io-p-vnet-common/subnets/io-p-eucovidcert-snet" -> null
                # (2 unchanged attributes hidden)
            }
          - ip_restriction {
              - action                    = "Allow" -> null
              - headers                   = [] -> null
              - name                      = "rule" -> null
              - priority                  = 65000 -> null
              - virtual_network_subnet_id = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.Network/virtualNetworks/io-p-vnet-common/subnets/appbackendl1" -> null
                # (2 unchanged attributes hidden)
            }
          - ip_restriction {
              - action                    = "Allow" -> null
              - headers                   = [] -> null
              - name                      = "rule" -> null
              - priority                  = 65000 -> null
              - virtual_network_subnet_id = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.Network/virtualNetworks/io-p-vnet-common/subnets/appbackendl2" -> null
                # (2 unchanged attributes hidden)
            }
          - ip_restriction {
              - action                    = "Allow" -> null
              - headers                   = [] -> null
              - name                      = "rule" -> null
              - priority                  = 65000 -> null
              - virtual_network_subnet_id = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.Network/virtualNetworks/io-p-vnet-common/subnets/apimv2api" -> null
                # (2 unchanged attributes hidden)
            }
          - ip_restriction {
              - action                    = "Allow" -> null
              - headers                   = [] -> null
              - name                      = "rule" -> null
              - priority                  = 65000 -> null
              - virtual_network_subnet_id = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.Network/virtualNetworks/io-p-vnet-common/subnets/appbackendl3" -> null
                # (2 unchanged attributes hidden)
            }
          - ip_restriction {
              - action                    = "Allow" -> null
              - name                      = "rule" -> null
              - priority                  = 65000 -> null
              - virtual_network_subnet_id = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-common-rg-01/providers/Microsoft.Network/virtualNetworks/io-p-itn-common-vnet-01/subnets/io-p-itn-apim-snet-01" -> null
                # (2 unchanged attributes hidden)
            }
        }
    }

Plan: 0 to add, 1 to change, 3 to destroy.

─────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't
guarantee to take exactly these actions if you run "terraform apply" now.

Copy link

@Krusty93
Copy link
Contributor

Krusty93 commented Jun 3, 2025

@iwoak We opened this PR few months ago to save some money as the function is rarely used. Are you interested in it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants