Skip to content

Commit

Permalink
[SELC-4512] Added apim group BFF proxy for ca (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuraf authored Mar 15, 2024
1 parent 6993663 commit 43ded57
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 20 deletions.
34 changes: 14 additions & 20 deletions infra/container_apps/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions infra/container_apps/apim.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
locals {
apim_name = format("selc-%s-apim", var.env_short)
apim_rg = format("selc-%s-api-rg", var.env_short)
api_name = format("selc-%s-api-bff-proxy", var.env_short)
}


resource "azurerm_api_management_api_version_set" "apim_api_bff_proxy" {
count = var.is_pnpg ? 0 : 1
name = local.api_name
resource_group_name = local.apim_rg
api_management_name = local.apim_name
display_name = "BFF Proxy API"
versioning_scheme = "Segment"
}


module "apim_api_bff_proxy" {
count = var.is_pnpg ? 0 : 1
source = "github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v7.50.1"
name = local.api_name
api_management_name = local.apim_name
resource_group_name = local.apim_rg
version_set_id = azurerm_api_management_api_version_set.apim_api_bff_proxy[0].id

description = "BFF Proxy API"
display_name = "BFF Proxy API"
path = "party-registry-proxy/v1"
protocols = [
"https"
]

service_url = format("https://%s", var.private_dns_name)

content_format = "openapi+json"
content_value = templatefile("../../app/src/main/resources/swagger/api-docs.json", {
url = format("%s.%s", var.api_dns_zone_prefix, var.external_domain)
basePath = "/party-registry-proxy/v1"
})

subscription_required = false

xml_content = <<XML
<policies>
<inbound>
<cors>
<allowed-origins>
<origin>https://${var.dns_zone_prefix}.${var.external_domain}</origin>
<origin>https://${var.api_dns_zone_prefix}.${var.external_domain}</origin>
<origin>http://localhost:3000</origin>
</allowed-origins>
<allowed-methods>
<method>GET</method>
<method>POST</method>
<method>PUT</method>
<method>DELETE</method>
<method>HEAD</method>
<method>OPTIONS</method>
</allowed-methods>
<allowed-headers>
<header>*</header>
</allowed-headers>
</cors>
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
XML
}
3 changes: 3 additions & 0 deletions infra/container_apps/env/dev/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
env_short = "d"
private_dns_name = "selc-d-party-reg-proxy-ca.gentleflower-c63e62fe.westeurope.azurecontainerapps.io"
dns_zone_prefix = "dev.selfcare"
api_dns_zone_prefix = "api.dev.selfcare"

tags = {
CreatedBy = "Terraform"
Expand Down
3 changes: 3 additions & 0 deletions infra/container_apps/env/prod/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
env_short = "p"
private_dns_name = "selc-p-party-reg-proxy-ca.bluedune-cc0f8752.westeurope.azurecontainerapps.io"
dns_zone_prefix = "selfcare"
api_dns_zone_prefix = "api.selfcare"

tags = {
CreatedBy = "Terraform"
Expand Down
3 changes: 3 additions & 0 deletions infra/container_apps/env/uat/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
env_short = "u"
private_dns_name = "selc-u-party-reg-proxy-ca.calmsky-143987c1.westeurope.azurecontainerapps.io"
dns_zone_prefix = "uat.selfcare"
api_dns_zone_prefix = "api.uat.selfcare"

tags = {
CreatedBy = "Terraform"
Expand Down
23 changes: 23 additions & 0 deletions infra/container_apps/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,26 @@ variable "secrets_names" {
type = map(string)
description = "KeyVault secrets to get values from"
}

variable "private_dns_name" {
type = string
description = "Container Apps private DNS record"
}

variable "external_domain" {
type = string
default = "pagopa.it"
description = "Domain for delegation"
}

variable "dns_zone_prefix" {
type = string
default = "selfcare"
description = "The dns subdomain."
}

variable "api_dns_zone_prefix" {
type = string
default = "api.selfcare"
description = "The dns subdomain."
}

0 comments on commit 43ded57

Please sign in to comment.