generated from pagopa/template-java-spring-microservice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VAS-506] updated infra to create dedicate apim product for backoffic…
…e external and helpdesk
- Loading branch information
giomella
committed
Mar 5, 2024
1 parent
25d1810
commit 8bac84c
Showing
2 changed files
with
116 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,146 @@ | ||
locals { | ||
repo_name = "pagopa-backoffice-external" | ||
apim_backoffice_external_api = { | ||
// Backoffice External | ||
display_name = "Selfcare Backoffice External Product pagoPA" | ||
description = "API for Backoffice External" | ||
path = "backoffice/external" | ||
subscription_required = true | ||
service_url = null | ||
} | ||
apim_backoffice_helpdesk_api = { | ||
// Helpdesk | ||
display_name = "Backoffice Helpdesk" | ||
description = "API for helpdesk on Backoffice" | ||
path = "backoffice/helpdesk" | ||
subscription_required = true | ||
service_url = null | ||
} | ||
|
||
display_name = "Selfcare Backoffice External Product pagoPA" | ||
description = "API for Backoffice External" | ||
path = "backoffice/external" | ||
|
||
host = "api.${var.apim_dns_zone_prefix}.${var.external_domain}" | ||
hostname = var.hostname | ||
} | ||
|
||
resource "azurerm_api_management_group" "api_group" { | ||
name = local.apim.product_id | ||
############## | ||
## Products ## | ||
############## | ||
|
||
// Backoffice External user(s) | ||
module "apim_backoffice_external_product" { | ||
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_product?ref=v6.4.1" | ||
|
||
product_id = "backoffice-external" | ||
display_name = local.apim_backoffice_external_api.display_name | ||
description = local.apim_backoffice_external_api.description | ||
|
||
api_management_name = local.apim.name | ||
resource_group_name = local.apim.rg | ||
|
||
published = true | ||
subscription_required = local.apim_backoffice_external_api.subscription_required | ||
approval_required = true | ||
subscriptions_limit = 1000 | ||
|
||
policy_xml = file("./api_product/backoffice-external/_base_policy.xml") | ||
} | ||
|
||
// Helpdesk | ||
module "apim_backoffice_helpdesk_product" { | ||
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_product?ref=v6.4.1" | ||
|
||
product_id = "backoffice-helpdesk" | ||
display_name = local.apim_backoffice_helpdesk_api.display_name | ||
description = local.apim_backoffice_helpdesk_api.description | ||
|
||
api_management_name = local.apim.name | ||
display_name = local.display_name | ||
description = local.description | ||
resource_group_name = local.apim.rg | ||
|
||
published = false | ||
subscription_required = local.apim_backoffice_helpdesk_api.subscription_required | ||
approval_required = true | ||
subscriptions_limit = 1000 | ||
|
||
policy_xml = file("./api_product/backoffice-helpdesk/_base_policy.xml") | ||
} | ||
|
||
resource "azurerm_api_management_api_version_set" "api_version_set" { | ||
name = format("%s-${local.repo_name}", var.env_short) | ||
|
||
############## | ||
## Api Vers ## | ||
############## | ||
|
||
resource "azurerm_api_management_api_version_set" "api_backoffice_external_api" { | ||
|
||
name = format("%s-backoffice-external-api", var.env_short) | ||
resource_group_name = local.apim.rg | ||
api_management_name = local.apim.name | ||
display_name = local.display_name | ||
display_name = local.apim_backoffice_external_api.display_name | ||
versioning_scheme = "Segment" | ||
} | ||
|
||
module "api_v1" { | ||
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v6.7.0" | ||
resource "azurerm_api_management_api_version_set" "api_backoffice_helpdesk_api" { | ||
|
||
name = format("%s-${local.repo_name}", var.env_short) | ||
name = format("%s-backoffice-helpdesk-api", var.env_short) | ||
resource_group_name = local.apim.rg | ||
api_management_name = local.apim.name | ||
display_name = local.apim_backoffice_helpdesk_api.display_name | ||
versioning_scheme = "Segment" | ||
} | ||
|
||
|
||
############## | ||
## OpenApi ## | ||
############## | ||
|
||
module "apim_api_backoffice_external_api_v1" { | ||
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v6.4.1" | ||
|
||
name = format("%s-backoffice-external-api", var.env_short) | ||
api_management_name = local.apim.name | ||
resource_group_name = local.apim.rg | ||
product_ids = [local.apim.product_id] | ||
subscription_required = true | ||
product_ids = [module.apim_backoffice_external_product.product_id] | ||
subscription_required = local.apim_backoffice_external_api.subscription_required | ||
version_set_id = azurerm_api_management_api_version_set.api_backoffice_external_api.id | ||
api_version = "v1" | ||
|
||
version_set_id = azurerm_api_management_api_version_set.api_version_set.id | ||
api_version = "v1" | ||
|
||
description = local.description | ||
display_name = local.display_name | ||
path = local.path | ||
description = local.apim_backoffice_external_api.description | ||
display_name = local.apim_backoffice_external_api.display_name | ||
path = local.apim_backoffice_external_api.path | ||
protocols = ["https"] | ||
|
||
service_url = null | ||
service_url = local.apim_backoffice_external_api.service_url | ||
|
||
content_format = "openapi" | ||
content_value = templatefile("../openapi/openapi.json", { | ||
content_value = templatefile("./api/backoffice-external/v1/_openapi.json.tpl", { | ||
host = local.host | ||
}) | ||
|
||
xml_content = templatefile("./policy/_base_policy.xml", { | ||
hostname = var.hostname | ||
xml_content = templatefile("./api/backoffice-external/v1/_base_policy.xml", { | ||
hostname = local.hostname | ||
}) | ||
} | ||
|
||
api_operation_policies = [ | ||
{ | ||
operation_id = "getCreditorInstitutions", | ||
xml_content = templatefile("./api/pagopa-backoffice-external/_get_broker_institutions_policy.xml", {}) | ||
}, | ||
] | ||
module "apim_api_backoffice_helpdesk_api_v1" { | ||
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v6.4.1" | ||
|
||
} | ||
name = format("%s-backoffice-helpdesk-api", var.env_short) | ||
api_management_name = local.apim.name | ||
resource_group_name = local.apim.rg | ||
product_ids = [module.apim_backoffice_helpdesk_product.product_id] | ||
subscription_required = local.apim_backoffice_helpdesk_api.subscription_required | ||
version_set_id = azurerm_api_management_api_version_set.api_backoffice_helpdesk_api.id | ||
api_version = "v1" | ||
|
||
description = local.apim_backoffice_helpdesk_api.description | ||
display_name = local.apim_backoffice_helpdesk_api.display_name | ||
path = local.apim_backoffice_helpdesk_api.path | ||
protocols = ["https"] | ||
service_url = local.apim_backoffice_helpdesk_api.service_url | ||
|
||
content_format = "openapi" | ||
content_value = templatefile("./api/backoffice-helpdesk/v1/_openapi.json.tpl", { | ||
host = local.host | ||
}) | ||
|
||
xml_content = templatefile("./api/backoffice-helpdesk/v1/_base_policy.xml", { | ||
hostname = local.hostname | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters