Skip to content

Commit

Permalink
[SELC-4510] Added apim group BFF dashboard for ca (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuraf authored Mar 15, 2024
1 parent d99bac7 commit bf1e304
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 34 deletions.
4 changes: 2 additions & 2 deletions app/src/main/resources/swagger/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4357,7 +4357,7 @@
},
"products" : {
"type" : "array",
"description" : "${swagger.dashboard.institutions.model.products}",
"description" : "Authorized user products",
"items" : {
"$ref" : "#/components/schemas/OnboardedProductResource"
}
Expand Down Expand Up @@ -5353,7 +5353,7 @@
"additionalProperties" : {
"$ref" : "#/components/schemas/WorkContactResource"
},
"description" : "${swagger.dasuboard.user.model.workContacts}"
"description" : "User's workcontacts, contains the emails associated to every institution the user is assigned to"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void swaggerSpringPlugin() throws Exception {
Path basePath = Paths.get("src/main/resources/swagger/");
Files.createDirectories(basePath);
Files.write(basePath.resolve("api-docs.json"), formatted.getBytes());
assertTrue(content.contains("${"), "Generated swagger contains placeholders");
assertFalse(content.contains("${"), "Generated swagger contains placeholders");
});
}

Expand Down
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 = var.is_pnpg ? format("selc-%s-pnpg-api-bff-dashboard", var.env_short) : format("selc-%s-api-bff-dashboard", var.env_short)
display_name = var.is_pnpg ? "BFF PNPG Dashboard API" : "BFF Dashboard API"
base_path = var.is_pnpg ? "imprese/dashboard" : "dashboard"
}


resource "azurerm_api_management_api_version_set" "apim_api_bff_dashboard" {
name = local.api_name
resource_group_name = local.apim_rg
api_management_name = local.apim_name
display_name = local.display_name
versioning_scheme = "Segment"
}


module "apim_api_bff_dashboard" {
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_dashboard.id

description = local.display_name
display_name = local.display_name
path = local.base_path
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 = local.base_path
})

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>HEAD</method>
<method>DELETE</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
}
8 changes: 6 additions & 2 deletions infra/container_apps/env/dev-pnpg/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
is_pnpg = true
env_short = "d"

private_dns_name = "selc-d-pnpg-dashboard-backend-ca.whiteglacier-211c4885.westeurope.azurecontainerapps.io"
dns_zone_prefix = "pnpg.dev.selfcare"
api_dns_zone_prefix = "api-pnpg.dev.selfcare"

tags = {
CreatedBy = "Terraform"
Environment = "Dev"
Owner = "SelfCare"
Source = "https://github.com/pagopa/selfcare-dashboard-pnpg-backend"
Source = "https://github.com/pagopa/selfcare-dashboard-backend"
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
}

Expand Down Expand Up @@ -108,7 +112,7 @@ app_settings = [
},
{
name = "SELFCARE_USER_URL"
value = "https://selc-d-user-ms-ca.whiteglacier-211c4885.westeurope.azurecontainerapps.io"
value = "https://selc-d-pnpg-user-ms-ca.whiteglacier-211c4885.westeurope.azurecontainerapps.io"
}
]

Expand Down
5 changes: 4 additions & 1 deletion infra/container_apps/env/dev/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
env_short = "d"
env_short = "d"
private_dns_name = "selc-d-dashboard-backend-ca.gentleflower-c63e62fe.westeurope.azurecontainerapps.io"
dns_zone_prefix = "dev.selfcare"
api_dns_zone_prefix = "api.dev.selfcare"

tags = {
CreatedBy = "Terraform"
Expand Down
7 changes: 5 additions & 2 deletions infra/container_apps/env/prod-pnpg/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
is_pnpg = true
env_short = "p"
private_dns_name = "selc-p-dashboard-backend-ca.salmonpond-602699235.westeurope.azurecontainerapps.io"
dns_zone_prefix = "imprese.notifichedigitali"
api_dns_zone_prefix = "api-pnpg.selfcare"

tags = {
CreatedBy = "Terraform"
Environment = "Prod"
Owner = "SelfCare"
Source = "https://github.com/pagopa/selfcare-dashboarp-pnpg-backend"
Source = "https://github.com/pagopa/selfcare-dashboard-backend"
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
}

Expand Down Expand Up @@ -121,7 +124,7 @@ app_settings = [
},
{
name = "SELFCARE_USER_URL"
value = "https://selc-d-user-ms-ca.salmonpond-602699235.westeurope.azurecontainerapps.io"
value = "https://selc-p-pnpg-user-ms-ca.salmonpond-602699235.westeurope.azurecontainerapps.io"
}
]

Expand Down
5 changes: 4 additions & 1 deletion 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-dashboard-backend-ca.bluedune-cc0f8752.westeurope.azurecontainerapps.io"
dns_zone_prefix = "selfcare"
api_dns_zone_prefix = format("api.%s, var.dns_zone_prefix)
tags = {
CreatedBy = "Terraform"
Expand Down Expand Up @@ -120,7 +123,7 @@ app_settings = [
},
{
name = "SELFCARE_USER_URL"
value = "https://selc-d-user-ms-ca.bluedune-cc0f8752.westeurope.azurecontainerapps.io"
value = "https://selc-p-user-ms-ca.bluedune-cc0f8752.westeurope.azurecontainerapps.io"
}
]

Expand Down
7 changes: 5 additions & 2 deletions infra/container_apps/env/uat-pnpg/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
is_pnpg = true
env_short = "u"
private_dns_name = "selc-u-dashboard-backend-ca.redground-be752d1f5.westeurope.azurecontainerapps.io"
dns_zone_prefix = "imprese.uat.notifichedigitali"
api_dns_zone_prefix = "api-pnpg.uat.selfcare"

tags = {
CreatedBy = "Terraform"
Environment = "Uat"
Owner = "SelfCare"
Source = "https://github.com/pagopa/selfcare-dashboaru-pnpg-backend"
Source = "https://github.com/pagopa/selfcare-dashboard-backend"
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
}

Expand Down Expand Up @@ -108,7 +111,7 @@ app_settings = [
},
{
name = "SELFCARE_USER_URL"
value = "https://selc-d-user-ms-ca.redground-be752d1f5.westeurope.azurecontainerapps.io"
value = "https://selc-u-pnpg-user-ms-ca.redground-be752d1f5.westeurope.azurecontainerapps.io"
}
]

Expand Down
5 changes: 4 additions & 1 deletion 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-dashboard-backend-ca.calmsky-143987c1.westeurope.azurecontainerapps.io"
dns_zone_prefix = "uat.selfcare"
api_dns_zone_prefix = format("api.%s, var.dns_zone_prefix)
tags = {
CreatedBy = "Terraform"
Expand Down Expand Up @@ -107,7 +110,7 @@ app_settings = [
},
{
name = "SELFCARE_USER_URL"
value = "https://selc-d-user-ms-ca.calmsky-143987c1.westeurope.azurecontainerapps.io"
value = "https://selc-u-user-ms-ca.calmsky-143987c1.westeurope.azurecontainerapps.io"
}
]

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."
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class InstitutionResource {
@ApiModelProperty(value = "${swagger.dashboard.institutions.model.parentDescription}")
private String parentDescription;

@ApiModelProperty(value = "${swagger.dashboard.institutions.model.products}")
@ApiModelProperty(value = "${swagger.dashboard.user.model.products}")
private List<OnboardedProductResource> products;

@ApiModelProperty(value = "${swagger.dashboard.institutions.model.city}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class UserResource {
@ApiModelProperty(value = "${swagger.dashboard.user.model.fiscalCode}")
private String fiscalCode;

@ApiModelProperty(value = "${swagger.dasuboard.user.model.workContacts}")
@ApiModelProperty(value = "${swagger.dashboard.user.model.workContacts}")
private Map<String, WorkContactResource> workContacts;

}

0 comments on commit bf1e304

Please sign in to comment.