diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index dcab2d61..590dbbf2 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -96,7 +96,7 @@ postgresql-replica: !!merge <<: *microservice-chart ingress: !!merge <<: *ingress - path: /api-config-cache/p(/|$)(.*) + path: /api-config-cache/pr(/|$)(.*) envConfig: !!merge <<: *envConfig APPLICATIONINSIGHTS_ROLE_NAME: "pagopa-api-config-cache-postgresql-replica" diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 3e0e214c..a8bf167d 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -87,7 +87,7 @@ postgresql-replica: !!merge <<: *microservice-chart ingress: !!merge <<: *ingress - path: /api-config-cache/p(/|$)(.*) + path: /api-config-cache/pr(/|$)(.*) envConfig: !!merge <<: *envConfig APPLICATIONINSIGHTS_ROLE_NAME: "pagopa-api-config-cache-postgresql-replica" @@ -131,6 +131,7 @@ refresh-p: namespace: "apiconfig" schedule: "0 0 * * *" timeZone: "Europe/Rome" + successfulJobsHistoryLimit: "1" image: repository: "curlimages/curl" tag: "latest" @@ -173,6 +174,7 @@ refresh-p-replica: namespace: "apiconfig" schedule: "0 0 * * *" timeZone: "Europe/Rome" + successfulJobsHistoryLimit: "1" image: repository: "curlimages/curl" tag: "latest" @@ -215,6 +217,7 @@ refresh-o: namespace: "apiconfig" schedule: "0 0 * * *" timeZone: "Europe/Rome" + successfulJobsHistoryLimit: "1" image: repository: "curlimages/curl" tag: "latest" diff --git a/infra/04_apim_export.tf b/infra/04_apim_export.tf new file mode 100644 index 00000000..c55c08c6 --- /dev/null +++ b/infra/04_apim_export.tf @@ -0,0 +1,162 @@ + +# Postgres + +resource "azurerm_api_management_api_version_set" "api_apiconfig_cache_export_node_api_p" { + name = format("%s-apicfg-cache-export-%s-api", var.env_short, local.postgres) + resource_group_name = local.apim.rg + api_management_name = local.apim.name + display_name = "${local.apiconfig_cache_export_locals.display_name} - Export Node ${local.postgres}" + versioning_scheme = "Segment" +} + +module "apim_api_apiconfig_cache_export_node_api_v1_p" { + source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v5.1.0" + name = format("%s-apicfg-cache-export-%s-api", local.project, local.postgres) + api_management_name = local.apim.name + resource_group_name = local.apim.rg + product_ids = [local.apim.product_id, local.technical_support_product_id] + subscription_required = local.apiconfig_cache_export_locals.subscription_required + + version_set_id = azurerm_api_management_api_version_set.api_apiconfig_cache_export_node_api_p.id + api_version = "v1" + + description = local.apiconfig_cache_export_locals.description + display_name = "${local.apiconfig_cache_export_locals.display_name} - Node ${local.postgres}" + + path = "${local.apiconfig_cache_export_locals.path_apim}/${local.postgres}" + protocols = ["https"] + service_url = local.apiconfig_cache_export_locals.service_url + + content_format = "openapi" + content_value = templatefile("../openapi/openapi_export.json", { + host = local.apim.hostname + service = "node-${local.postgres}" + }) + + xml_content = templatefile("./policy/_base_policy.xml", { + hostname = local.apiconfig_cache_export_locals.hostname + hostname = format("%s/%s", local.apiconfig_cache_export_locals.hostname, "${local.apiconfig_cache_export_locals.path}/${local.postgres}") + }) +} + +# Oracle + +resource "azurerm_api_management_api_version_set" "api_apiconfig_cache_export_node_api_o" { + name = format("%s-apicfg-cache-export-%s-api", var.env_short, local.oracle) + resource_group_name = local.apim.rg + api_management_name = local.apim.name + display_name = "${local.apiconfig_cache_export_locals.display_name} - Node ${local.oracle}" + versioning_scheme = "Segment" +} + +module "apim_api_apiconfig_cache_export_node_api_v1_o" { + source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v5.1.0" + + name = format("%s-apicfg-cache-export-%s-api", local.project, local.oracle) + api_management_name = local.apim.name + resource_group_name = local.apim.rg + product_ids = [local.apim.product_id, local.technical_support_product_id] + subscription_required = local.apiconfig_cache_export_locals.subscription_required + + version_set_id = azurerm_api_management_api_version_set.api_apiconfig_cache_export_node_api_o.id + api_version = "v1" + + description = local.apiconfig_cache_export_locals.description + display_name = "${local.apiconfig_cache_export_locals.display_name} - Node ${local.oracle}" + + path = "${local.apiconfig_cache_export_locals.path_apim}/${local.oracle}" + protocols = ["https"] + service_url = local.apiconfig_cache_export_locals.service_url + + content_format = "openapi" + content_value = templatefile("../openapi/openapi_export.json", { + host = local.apim.hostname + service = "node-${local.oracle}" + }) + + xml_content = templatefile("./policy/_base_policy.xml", { + hostname = local.apiconfig_cache_locals.hostname + hostname = format("%s/%s", local.apiconfig_cache_export_locals.hostname, "${local.apiconfig_cache_export_locals.path}/${local.oracle}") + }) +} + +resource "azurerm_api_management_api_version_set" "api_apiconfig_cache_replica_export_node_api_p" { + count = var.env_short == "p" ? 0 : 1 + name = format("%s-apicfg-cache-export-replica-node-%s-api", var.env_short, "p") + resource_group_name = local.apim.rg + api_management_name = local.apim.name + display_name = "${local.apiconfig_cache_replica_export_locals.display_name} - Node p" + versioning_scheme = "Segment" +} + +resource "azurerm_api_management_api_version_set" "api_apiconfig_cache_replica_export_node_api_o" { + count = var.env_short == "p" ? 0 : 1 + name = format("%s-apicfg-cache-replica-export-%s-api", var.env_short, "o") + resource_group_name = local.apim.rg + api_management_name = local.apim.name + display_name = "${local.apiconfig_cache_replica_export_locals.display_name} - Node o" + versioning_scheme = "Segment" +} + +module "apim_api_apiconfig_cache_replica_export_node_api_v1_p" { + source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v6.4.1" + count = var.env_short == "p" ? 0 : 1 + + name = format("%s-apicfg-cache-replica-export-%s-api", local.project, "p") + api_management_name = local.apim.name + resource_group_name = local.apim.rg + product_ids = [local.apim.product_id, local.technical_support_product_id] + subscription_required = local.apiconfig_cache_replica_export_locals.subscription_required + + version_set_id = azurerm_api_management_api_version_set.api_apiconfig_cache_replica_export_node_api_p[0].id + api_version = "v1" + + description = local.apiconfig_cache_replica_export_locals.description + display_name = "${local.apiconfig_cache_replica_export_locals.display_name} - Node p" + + path = format("%s/%s", local.apiconfig_cache_replica_export_locals.path_apim, "pr") + protocols = ["https"] + service_url = local.apiconfig_cache_replica_export_locals.service_url + + content_format = "openapi" + content_value = templatefile("../openapi/openapi_export.json", { + host = local.apim.hostname + service = "node-p-replica" + }) + + xml_content = templatefile("./policy/_base_policy.xml", { + hostname = format("%s/%s/%s", local.apiconfig_cache_replica_export_locals.hostname, local.apiconfig_cache_replica_export_locals.path, "pr") + }) +} + +module "apim_api_apiconfig_cache_replica_export_node_api_v1_o" { + source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v6.4.1" + count = var.env_short == "p" ? 0 : 1 + + name = format("%s-apicfg-cache-replica-export-%s-api", local.project, "o") + api_management_name = local.apim.name + resource_group_name = local.apim.rg + product_ids = [local.apim.product_id, local.technical_support_product_id] + subscription_required = local.apiconfig_cache_replica_export_locals.subscription_required + + version_set_id = azurerm_api_management_api_version_set.api_apiconfig_cache_replica_export_node_api_o[0].id + api_version = "v1" + + description = local.apiconfig_cache_replica_export_locals.description + display_name = "${local.apiconfig_cache_replica_export_locals.display_name} - Node o" + + path = format("%s/%s", local.apiconfig_cache_replica_export_locals.path_apim, "or") + protocols = ["https"] + service_url = local.apiconfig_cache_replica_export_locals.service_url + + content_format = "openapi" + content_value = templatefile("../openapi/openapi_export.json", { + host = local.apim.hostname + service = "node-o-replica" + }) + + xml_content = templatefile("./policy/_base_policy.xml", { + hostname = format("%s/%s/%s", local.apiconfig_cache_replica_export_locals.hostname, local.apiconfig_cache_replica_export_locals.path, "or") + }) +} + diff --git a/infra/99_locals.tf b/infra/99_locals.tf index a1f696ad..2d7bba0d 100644 --- a/infra/99_locals.tf +++ b/infra/99_locals.tf @@ -9,6 +9,7 @@ locals { hostname = "api.${var.apim_dns_zone_prefix}.${var.external_domain}" } apim_x_node_product_id = "apim_for_node" + technical_support_product_id = "technical_support_api" oracle = "o" postgres = "p" @@ -27,6 +28,7 @@ locals { pagopa_tenant_id = data.azurerm_client_config.current.tenant_id } + apiconfig_cache_replica_locals = { hostname = var.env == "prod" ? "weuprod.apiconfig.internal.platform.pagopa.it" : "weu${var.env}.apiconfig.internal.${var.env}.platform.pagopa.it" @@ -42,5 +44,35 @@ locals { pagopa_tenant_id = data.azurerm_client_config.current.tenant_id } + apiconfig_cache_export_locals = { + hostname = var.env == "prod" ? "weuprod.apiconfig.internal.platform.pagopa.it" : "weu${var.env}.apiconfig.internal.${var.env}.platform.pagopa.it" + + display_name = "API Config Cache - Export" + description = "Export API of configuration about pagoPA cache" + subscription_required = true + subscription_limit = 1000 + + path_apim = "api-config-cache/export" + path = "api-config-cache" + service_url = null + + pagopa_tenant_id = data.azurerm_client_config.current.tenant_id + } + + apiconfig_cache_replica_export_locals = { + hostname = var.env == "prod" ? "weuprod.apiconfig.internal.platform.pagopa.it" : "weu${var.env}.apiconfig.internal.${var.env}.platform.pagopa.it" + + display_name = "API Config Cache Replica - Export" + description = "Export API of configuration about pagoPA cache replica" + subscription_required = true + subscription_limit = 1000 + + path_apim = "api-config-cache/export" + path = "api-config-cache" + service_url = null + + pagopa_tenant_id = data.azurerm_client_config.current.tenant_id + } + }