diff --git a/src/rtp/02_api_service_provider.tf b/src/rtp/02_api_service_provider.tf new file mode 100644 index 0000000..f4b0f12 --- /dev/null +++ b/src/rtp/02_api_service_provider.tf @@ -0,0 +1,54 @@ +## RTP Service Provider API ## +resource "azurerm_api_management_api_version_set" "rtp_service_provider_api" { + name = "${var.env_short}-rtp-service-provider-api" + api_management_name = data.azurerm_api_management.this.name + resource_group_name = data.azurerm_api_management.this.resource_group_name + + display_name = "RTP Service Provider API" + versioning_scheme = "Segment" +} + +resource "azurerm_api_management_api" "rtp_service_provider_api" { + name = "${var.env_short}-rtp-service-provider-api" + api_management_name = data.azurerm_api_management.this.name + resource_group_name = data.azurerm_api_management.this.resource_group_name + + version_set_id = azurerm_api_management_api_version_set.rtp_service_provider_api.id + + revision = "1" + version = "v1" + description = "RTP Service Provider API" + display_name = "RTP Service Provider API" + path = "rtp" + protocols = ["https"] + subscription_required = false + + depends_on = [azurerm_api_management_product.rtp] + + import { + content_format = "openapi" + content_value = templatefile("./api/pagopa/openapi.yaml", {}) + } +} + + +resource "azurerm_api_management_product_api" "rtp_service_provider_product_api" { + api_management_name = data.azurerm_api_management.this.name + resource_group_name = data.azurerm_api_management.this.resource_group_name + + api_name = azurerm_api_management_api.rtp_service_provider_api.name + product_id = azurerm_api_management_product.rtp.product_id + depends_on = [azurerm_api_management_product.rtp, azurerm_api_management_api.rtp_service_provider_api] +} + +## Override API Operations Policies ## +resource "azurerm_api_management_api_operation_policy" "rtp_service_provider_create_rtp_policy" { + api_name = azurerm_api_management_api.rtp_service_provider_api.name + api_management_name = azurerm_api_management_api.rtp_service_provider_api.api_management_name + resource_group_name = azurerm_api_management_api.rtp_service_provider_api.resource_group_name + operation_id = "createRtp" + + xml_content = templatefile("./api/pagopa/create_rtp_mock_policy.xml", { + base_url : "${local.rtp_base_url}/${azurerm_api_management_api.rtp_service_provider_api.path}/${azurerm_api_management_api.rtp_service_provider_api.version}/rtps" + }) +} diff --git a/src/rtp/99_locals.tf b/src/rtp/99_locals.tf index 01f792b..4cf1a64 100644 --- a/src/rtp/99_locals.tf +++ b/src/rtp/99_locals.tf @@ -4,4 +4,6 @@ locals { apim_name = "${local.product}-apim" apim_rg = "${local.product}-api-rg" + + rtp_base_url = "https://api-rtp.${var.dns_zone_prefix}" } \ No newline at end of file diff --git a/src/rtp/99_variables.tf b/src/rtp/99_variables.tf index 50b61b1..700c65a 100644 --- a/src/rtp/99_variables.tf +++ b/src/rtp/99_variables.tf @@ -48,3 +48,8 @@ variable "domain" { error_message = "Max length is 12 chars." } } + +variable "dns_zone_prefix" { + type = string + description = "The DNS zone prefix e.g. dev.cstar.pagopa.it" +} \ No newline at end of file diff --git a/src/rtp/api/pagopa/create_rtp_mock_policy.xml b/src/rtp/api/pagopa/create_rtp_mock_policy.xml new file mode 100644 index 0000000..dcc92de --- /dev/null +++ b/src/rtp/api/pagopa/create_rtp_mock_policy.xml @@ -0,0 +1,35 @@ + + + + + + + + application/json + + + @("${base_url}" + "/" + context.Variables["uuid"]) + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/rtp/api/pagopa/openapi.yaml b/src/rtp/api/pagopa/openapi.yaml index 65db114..e491ea1 100644 --- a/src/rtp/api/pagopa/openapi.yaml +++ b/src/rtp/api/pagopa/openapi.yaml @@ -60,6 +60,7 @@ components: $ref: "#/components/schemas/PayeeId" name: type: string + maxLength: 140 description: "The name of payee (e.g. EC name or Company Name)" example: "Comune di Roma" required: diff --git a/src/rtp/env/dev/terraform.tfvars b/src/rtp/env/dev/terraform.tfvars index 76d3cdd..42ffd35 100644 --- a/src/rtp/env/dev/terraform.tfvars +++ b/src/rtp/env/dev/terraform.tfvars @@ -14,3 +14,5 @@ tags = { CostCenter = "TS310 - PAGAMENTI & SERVIZI" Application = "RTP" } + +dns_zone_prefix = "dev.cstar.pagopa.it" \ No newline at end of file diff --git a/src/rtp/env/prod/terraform.tfvars b/src/rtp/env/prod/terraform.tfvars index 9592fb6..46b8094 100644 --- a/src/rtp/env/prod/terraform.tfvars +++ b/src/rtp/env/prod/terraform.tfvars @@ -14,3 +14,5 @@ tags = { CostCenter = "TS310 - PAGAMENTI & SERVIZI" Application = "RTP" } + +dns_zone_prefix = "cstar.pagopa.it" \ No newline at end of file diff --git a/src/rtp/env/uat/terraform.tfvars b/src/rtp/env/uat/terraform.tfvars index b60828f..e798846 100644 --- a/src/rtp/env/uat/terraform.tfvars +++ b/src/rtp/env/uat/terraform.tfvars @@ -14,3 +14,5 @@ tags = { CostCenter = "TS310 - PAGAMENTI & SERVIZI" Application = "RTP" } + +dns_zone_prefix = "uat.cstar.pagopa.it" \ No newline at end of file