resource "azurerm_api_management_api_version_set" "generic_client_systems" { for_each = local.tenants__map resource_group_name = azurerm_resource_group.this.name api_management_name = azurerm_api_management.this.name name = "${each.value.api_path}-revision-${local.v2_api_revision}" display_name = each.value.display_name versioning_scheme = "Segment" } resource "azurerm_api_management_api" "generic_client_systems" { for_each = local.tenants__map name = "${each.value.api_path}-v2" resource_group_name = azurerm_resource_group.this.name api_management_name = azurerm_api_management.this.name revision = local.v2_api_revision display_name = each.value.display_name path = each.value.api_path protocols = ["https"] version = "v2" version_set_id = azurerm_api_management_api_version_set.generic_client_systems["${each.value.tenant_code}"].id import { content_format = "openapi" content_value = replace(file("./data/API.yaml"), "title: XYZ", "title: ${each.value.display_name}") } } resource "azurerm_api_management_api_policy" "generic_client_systems" { for_each = local.tenants__map api_name = azurerm_api_management_api.generic_client_systems["${each.value.tenant_code}"].name api_management_name = azurerm_api_management.this.name resource_group_name = azurerm_resource_group.this.name xml_content = templatefile( "./data/policies/client_systems_api_policy.xml", { # secrets removed } ) } resource "azurerm_api_management_product" "generic_client_systems" { for_each = local.tenants__map product_id = "${each.value.tenant_id}-api" api_management_name = azurerm_api_management.this.name resource_group_name = azurerm_resource_group.this.name display_name = each.value.display_name subscription_required = true approval_required = true published = true subscriptions_limit = 100 } resource "azurerm_api_management_product_api" "generic_client_systems" { for_each = local.tenants__map api_name = azurerm_api_management_api.generic_client_systems["${each.value.tenant_code}"].name product_id = azurerm_api_management_product.generic_client_systems["${each.value.tenant_code}"].product_id api_management_name = azurerm_api_management.this.name resource_group_name = azurerm_api_management.this.resource_group_name } resource "azurerm_api_management_subscription" "generic_client_systems" { for_each = local.tenants__map api_management_name = azurerm_api_management.this.name resource_group_name = azurerm_resource_group.this.name display_name = "${each.value.display_name} subscription" product_id = azurerm_api_management_product.generic_client_systems["${each.value.tenant_code}"].id state = "active" allow_tracing = false }