Skip to content

Commit

Permalink
feat: configured itn apim migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mamu0 committed Nov 4, 2024
1 parent 17948a8 commit 1bde29e
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 4 deletions.
92 changes: 92 additions & 0 deletions infra/resources/_modules/apim/apim_itn.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// IO WEB API
module "apim_itn_web_wallet_api" {
source = "git::https://github.com/pagopa/terraform-azurerm-v3//api_management_api?ref=v8.12.2"

name = format("%s-ioweb-wallet", var.project_legacy)
api_management_name = var.apim.name
resource_group_name = var.apim.resource_group_name
product_ids = [var.product_id]
subscription_required = false

service_url = format("https://%s/api/v1/wallet", var.function_apps.user_function.function_hostname)

description = "Wallet APIs"
display_name = "IO Web - Wallet"
path = "ioweb/wallet/api/${var.revision}"
protocols = ["https"]

content_format = "openapi"

# NOTE: This openapi does not contains `upgradeToken` endpoint, since it's not necessary
content_value = file("${path.module}/api/ioweb/user-function/_swagger.json")

xml_content = file("${path.module}/api/ioweb/user-function/_base_policy.xml")
}

# resource "azurerm_api_management_named_value" "user_func_key" {
# name = "io-wallet-user-func-key"
# api_management_name = var.apim.name
# resource_group_name = var.apim.resource_group_name
# display_name = "io-wallet-user-func-key"
# value = data.azurerm_key_vault_secret.funciowallet_default.value
# secret = "true"
# }

# data "azurerm_key_vault_secret" "funciowallet_default" {
# name = "funciowallet-KEY-APPBACKEND"
# key_vault_id = var.key_vault_id
# }

// SUPPORT API
module "apim_itn_wallet_support_api" {
source = "git::https://github.com/pagopa/terraform-azurerm-v3//api_management_api?ref=v8.12.2"

name = format("%s-wallet-support-api", var.project_legacy)
api_management_name = var.apim.name
resource_group_name = var.apim.resource_group_name
product_ids = [module.apim_itn_wallet_support_product.product_id]
subscription_required = true

service_url = format("https://%s/api/v1/wallet", var.function_apps.support_function.function_hostname)


description = "API for Wallet Support Assistance"
display_name = "IO Wallet - Support"
path = "api/v1/wallet/support"
protocols = ["https"]

content_format = "openapi"

content_value = file("${path.module}/api/support-function/_swagger.json")

xml_content = file("${path.module}/api/support-function/_base_policy.xml")
}

# resource "azurerm_api_management_named_value" "support_func_key" {
# name = "io-wallet-support-func-key"
# api_management_name = var.apim.name
# resource_group_name = var.apim.resource_group_name
# display_name = "io-wallet-support-func-key"
# value = data.azurerm_key_vault_secret.support_func_key_default.value
# secret = "true"
# }

# data "azurerm_key_vault_secret" "support_func_key_default" {
# name = "io-wallet-support-func-key"
# key_vault_id = var.key_vault_wallet_id
# }

module "apim_itn_wallet_support_product" {
source = "github.com/pagopa/terraform-azurerm-v3//api_management_product?ref=v8.27.0"

product_id = format("%s-wallet-support-api", var.project_legacy)
display_name = "IO WALLET SUPPORT API"
description = "Product containing APIs for Wallet Support Assistance"

api_management_name = var.apim.name
resource_group_name = var.apim.resource_group_name

published = true
subscription_required = true
approval_required = false
}
6 changes: 4 additions & 2 deletions infra/resources/_modules/apim/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ variable "tags" {

variable "apim" {
type = object({
name = string
resource_group_name = string
name = string
resource_group_name = string
name_itn = optional(string)
resource_group_name_itn = optional(string)
})
description = "APIM configuration variables"
}
Expand Down
5 changes: 5 additions & 0 deletions infra/resources/prod/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ locals {
}
}

apim_itn = {
name = "${local.project}-apim-01"
resource_group_name = "${local.project}-common-rg-01"
}

tags = {
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
CreatedBy = "Terraform"
Expand Down
6 changes: 4 additions & 2 deletions infra/resources/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ module "apim" {

project_legacy = local.project_legacy
apim = {
name = local.apim.name
resource_group_name = local.apim.resource_group_name
name = local.apim.name
resource_group_name = local.apim.resource_group_name
name_itn = local.apim_itn.name
resource_group_name_itn = local.apim_itn.resource_group_name
}

function_apps = {
Expand Down

0 comments on commit 1bde29e

Please sign in to comment.