Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export api cfg cache #53

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -131,6 +131,7 @@ refresh-p:
namespace: "apiconfig"
schedule: "0 0 * * *"
timeZone: "Europe/Rome"
successfulJobsHistoryLimit: "1"
image:
repository: "curlimages/curl"
tag: "latest"
Expand Down Expand Up @@ -173,6 +174,7 @@ refresh-p-replica:
namespace: "apiconfig"
schedule: "0 0 * * *"
timeZone: "Europe/Rome"
successfulJobsHistoryLimit: "1"
image:
repository: "curlimages/curl"
tag: "latest"
Expand Down Expand Up @@ -215,6 +217,7 @@ refresh-o:
namespace: "apiconfig"
schedule: "0 0 * * *"
timeZone: "Europe/Rome"
successfulJobsHistoryLimit: "1"
image:
repository: "curlimages/curl"
tag: "latest"
Expand Down
162 changes: 162 additions & 0 deletions infra/04_apim_export.tf
Original file line number Diff line number Diff line change
@@ -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")
})
}

32 changes: 32 additions & 0 deletions infra/99_locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand All @@ -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
}

}

Loading