diff --git a/.github/workflows/validate-openapi.yaml b/.github/workflows/validate-openapi.yaml
index 6993bd7..d1eb7e6 100644
--- a/.github/workflows/validate-openapi.yaml
+++ b/.github/workflows/validate-openapi.yaml
@@ -3,8 +3,8 @@ name: Run Spectral on Pull Requests
on:
pull_request:
paths:
- - 'openapi/**/*.yaml'
- - 'openapi/**/*.yml'
+ - '**/api/**/*.yaml'
+ - '**/api/**/*.yml'
permissions:
checks: write
@@ -19,5 +19,5 @@ jobs:
# Run Spectral
- uses: stoplightio/spectral-action@2ad0b9302e32a77c1caccf474a9b2191a8060d83 #v0.8.11
with:
- file_glob: 'openapi/**/(*.yaml|*.yml)'
+ file_glob: '**/api/**/(*.yaml|*.yml)'
repo_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/scripts/terraform.sh b/scripts/terraform.sh
old mode 100644
new mode 100755
diff --git a/src/rtp/.terraform.lock.hcl b/src/rtp/.terraform.lock.hcl
new file mode 100644
index 0000000..a393664
--- /dev/null
+++ b/src/rtp/.terraform.lock.hcl
@@ -0,0 +1,42 @@
+# This file is maintained automatically by "terraform init".
+# Manual edits may be lost in future updates.
+
+provider "registry.terraform.io/hashicorp/azuread" {
+ version = "2.53.1"
+ constraints = "~> 2.52"
+ hashes = [
+ "h1:2rk36pu4YyhBVz/Mf4swYCQxaB31iPaXOiWNlqZMXbM=",
+ "zh:162916b037e5133f49298b0ffa3e7dcef7d76530a8ca738e7293373980f73c68",
+ "zh:1c3e89cf19118fc07d7b04257251fc9897e722c16e0a0df7b07fcd261f8c12e7",
+ "zh:492931cea4f30887ab5bca36a8556dfcb897288eddd44619c0217fc5da2d57e7",
+ "zh:4c895e450e18335ad8714cc6d3488fc1a78816ad2851a91b06cb2ef775dd7c66",
+ "zh:60d92fdaf7235574201f2d8f68f733ee00a822993b3fc95e6952e09e6ec76999",
+ "zh:67a169119efa41c1fb867ef1a8e79bf03472a2324384c36eb55370c817dcce42",
+ "zh:9dd4d5ed9233cf9329262200bc5a1aa60942b80dbc611e2ef4b09f47531b39b1",
+ "zh:a3c160e35b9e40fc1497b83c2f37a8e24565b05a1783c7733609f3695735c2a9",
+ "zh:a4a221da42b1f46e7c436c7145e5beaadfd9d03f3be6fd526d132c03f18a5979",
+ "zh:af0d3476a9702d2287e168e3baa670e64daab9c9b01c01e17025a5248f3e28e9",
+ "zh:e3579bff7894f3d36066b74ec324be6d28f56a42a387a2b8a0eabf33cbff86df",
+ "zh:f1749ee8ad972ae6424665aa9d2c0ece8c40c51d41ec2f38b863148cb437e865",
+ ]
+}
+
+provider "registry.terraform.io/hashicorp/azurerm" {
+ version = "3.116.0"
+ constraints = "~> 3.108"
+ hashes = [
+ "h1:2QbjtN4oMXzdA++Nvrj/wSmWZTPgXKOSFGGQCLEMrb4=",
+ "zh:02b6606aff025fc2a962b3e568e000300abe959adac987183c24dac8eb057f4d",
+ "zh:2a23a8ce24ff9e885925ffee0c3ea7eadba7a702541d05869275778aa47bdea7",
+ "zh:57d10746384baeca4d5c56e88872727cdc150f437b8c5e14f0542127f7475e24",
+ "zh:59e3ebde1a2e1e094c671e179f231ead60684390dbf02d2b1b7fe67a228daa1a",
+ "zh:5f1f5c7d09efa2ee8ddf21bd9efbbf8286f6e90047556bef305c062fa0ac5880",
+ "zh:a40646aee3c9907276dab926e6123a8d70b1e56174836d4c59a9992034f88d70",
+ "zh:c21d40461bc5836cf56ad3d93d2fc47f61138574a55e972ad5ff1cb73bab66dc",
+ "zh:c56fb91a5ae66153ba0f737a26da1b3d4f88fdef7d41c63e06c5772d93b26953",
+ "zh:d1e60e85f51d12fc150aeab8e31d3f18f859c32f927f99deb5b74cb1e10087aa",
+ "zh:ed35e727e7d79e687cd3d148f52b442961ede286e7c5b4da1dcd9f0128009466",
+ "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c",
+ "zh:f6d2a4e7c58f44e7d04a4a9c73f35ed452f412c97c85def68c4b52814cbe03ab",
+ ]
+}
diff --git a/src/rtp/00_data.tf b/src/rtp/00_data.tf
new file mode 100644
index 0000000..d5cbd42
--- /dev/null
+++ b/src/rtp/00_data.tf
@@ -0,0 +1,4 @@
+data "azurerm_api_management" "this" {
+ name = local.apim_name
+ resource_group_name = local.apim_rg
+}
\ No newline at end of file
diff --git a/src/rtp/01_apim_core.tf b/src/rtp/01_apim_core.tf
new file mode 100644
index 0000000..e70cab1
--- /dev/null
+++ b/src/rtp/01_apim_core.tf
@@ -0,0 +1,30 @@
+# ------------------------------------------------------------------------------
+# Product.
+# ------------------------------------------------------------------------------
+resource "azurerm_api_management_product" "rtp" {
+ api_management_name = data.azurerm_api_management.this.name
+ resource_group_name = data.azurerm_api_management.this.resource_group_name
+
+ product_id = "rtp"
+ display_name = "RTP Request To Pay"
+ description = "RTP Request To Pay"
+
+ subscription_required = false
+ published = true
+}
+
+resource "azurerm_api_management_product_policy" "rtp_api_product" {
+ product_id = azurerm_api_management_product.rtp.product_id
+ api_management_name = data.azurerm_api_management.this.name
+ resource_group_name = data.azurerm_api_management.this.resource_group_name
+
+ xml_content = file("./api_product/base_policy.xml")
+}
+
+resource "azurerm_api_management_group" "rtp_group" {
+ name = var.domain
+ resource_group_name = data.azurerm_api_management.this.resource_group_name
+ api_management_name = data.azurerm_api_management.this.name
+ display_name = upper(var.domain)
+}
+
diff --git a/src/rtp/02_api_mock.tf b/src/rtp/02_api_mock.tf
new file mode 100644
index 0000000..9dd064e
--- /dev/null
+++ b/src/rtp/02_api_mock.tf
@@ -0,0 +1,50 @@
+## RTP Mock API ##
+resource "azurerm_api_management_api" "rtp_mock_api" {
+ name = "${var.env_short}-rtp-mock-api"
+ api_management_name = data.azurerm_api_management.this.name
+ resource_group_name = data.azurerm_api_management.this.resource_group_name
+
+ revision = "1"
+ description = "RTP MOCK API"
+ display_name = "RTP MOCK API"
+ path = "rtp/mock"
+ protocols = ["https"]
+ subscription_required = false
+
+ depends_on = [azurerm_api_management_product.rtp]
+}
+
+resource "azurerm_api_management_product_api" "rtp_mock_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_mock_api.name
+ product_id = azurerm_api_management_product.rtp.product_id
+ depends_on = [azurerm_api_management_product.rtp, azurerm_api_management_api.rtp_mock_api]
+}
+
+
+## RTP Mock Operations ##
+resource "azurerm_api_management_api_operation" "rtp_mock_create_ticket" {
+ operation_id = "rtp_mock_create_ticket"
+ api_name = azurerm_api_management_api.rtp_mock_api.name
+ api_management_name = data.azurerm_api_management.this.name
+ resource_group_name = data.azurerm_api_management.this.resource_group_name
+ display_name = "RTP Mock create ticket"
+ method = "POST"
+ url_template = "/api/v1/create"
+ description = "Endpoint for create a rtp ticket api"
+}
+
+resource "azurerm_api_management_api_operation_policy" "rtp_mock_create_ticket_policy" {
+ api_name = azurerm_api_management_api_operation.rtp_mock_create_ticket.api_name
+ api_management_name = azurerm_api_management_api_operation.rtp_mock_create_ticket.api_management_name
+ resource_group_name = azurerm_api_management_api_operation.rtp_mock_create_ticket.resource_group_name
+ operation_id = azurerm_api_management_api_operation.rtp_mock_create_ticket.operation_id
+
+ xml_content = templatefile("./api/test/mock_policy.xml", {
+ env = var.env
+ })
+
+ depends_on = [azurerm_api_management_api_operation.rtp_mock_create_ticket]
+
+}
\ No newline at end of file
diff --git a/src/rtp/99_locals.tf b/src/rtp/99_locals.tf
new file mode 100644
index 0000000..01f792b
--- /dev/null
+++ b/src/rtp/99_locals.tf
@@ -0,0 +1,7 @@
+locals {
+ project = "${var.prefix}-${var.env_short}-${var.location_short}-${var.domain}"
+ product = "${var.prefix}-${var.env_short}"
+
+ apim_name = "${local.product}-apim"
+ apim_rg = "${local.product}-api-rg"
+}
\ No newline at end of file
diff --git a/src/rtp/99_main.tf b/src/rtp/99_main.tf
new file mode 100644
index 0000000..3bf6462
--- /dev/null
+++ b/src/rtp/99_main.tf
@@ -0,0 +1,29 @@
+terraform {
+ required_version = ">=1.3.0"
+
+ required_providers {
+ azuread = {
+ source = "hashicorp/azuread"
+ version = "~> 2.52"
+ }
+ azurerm = {
+ source = "hashicorp/azurerm"
+ version = "~> 3.108"
+ }
+ }
+
+ backend "azurerm" {}
+}
+
+provider "azurerm" {
+ features {
+ key_vault {
+ purge_soft_delete_on_destroy = false
+ }
+ }
+}
+
+module "__v3__" {
+ # https://github.com/pagopa/terraform-azurerm-v3/releases/tag/v8.39.0
+ source = "git::https://github.com/pagopa/terraform-azurerm-v3.git?ref=e64f39b63d46e8c05470e30eca873f44a0ab7f1b"
+}
\ No newline at end of file
diff --git a/src/rtp/99_variables.tf b/src/rtp/99_variables.tf
new file mode 100644
index 0000000..50b61b1
--- /dev/null
+++ b/src/rtp/99_variables.tf
@@ -0,0 +1,50 @@
+variable "prefix" {
+ type = string
+ validation {
+ condition = (
+ length(var.prefix) <= 6
+ )
+ error_message = "Max length is 6 chars."
+ }
+}
+
+variable "env" {
+ type = string
+ description = "Environment"
+}
+
+variable "env_short" {
+ type = string
+ validation {
+ condition = (
+ length(var.env_short) <= 1
+ )
+ error_message = "Max length is 1 chars."
+ }
+}
+
+variable "location" {
+ type = string
+}
+
+variable "location_short" {
+ type = string
+ description = "Location short like eg: neu, weu.."
+}
+
+variable "tags" {
+ type = map(any)
+ default = {
+ CreatedBy = "Terraform"
+ }
+}
+
+variable "domain" {
+ type = string
+ validation {
+ condition = (
+ length(var.domain) <= 12
+ )
+ error_message = "Max length is 12 chars."
+ }
+}
diff --git a/openapi/pagopa/openapi.yaml b/src/rtp/api/pagopa/openapi.yaml
similarity index 100%
rename from openapi/pagopa/openapi.yaml
rename to src/rtp/api/pagopa/openapi.yaml
diff --git a/src/rtp/api/test/mock_policy.xml b/src/rtp/api/test/mock_policy.xml
new file mode 100644
index 0000000..5507cb1
--- /dev/null
+++ b/src/rtp/api/test/mock_policy.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+ application/json
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/rtp/api_product/base_policy.xml b/src/rtp/api_product/base_policy.xml
new file mode 100644
index 0000000..dcfe583
--- /dev/null
+++ b/src/rtp/api_product/base_policy.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/rtp/env/dev/backend.ini b/src/rtp/env/dev/backend.ini
new file mode 100644
index 0000000..5d2d018
--- /dev/null
+++ b/src/rtp/env/dev/backend.ini
@@ -0,0 +1 @@
+subscription=DEV-CSTAR
\ No newline at end of file
diff --git a/src/rtp/env/dev/backend.tfvars b/src/rtp/env/dev/backend.tfvars
new file mode 100644
index 0000000..bf16ea1
--- /dev/null
+++ b/src/rtp/env/dev/backend.tfvars
@@ -0,0 +1,4 @@
+resource_group_name = "io-infra-rg"
+storage_account_name = "cstarinfrastterraformdev"
+container_name = "azurermstate"
+key = "rtp-apim-product-rtp-dev.terraform.tfstate"
\ No newline at end of file
diff --git a/src/rtp/env/dev/terraform.tfvars b/src/rtp/env/dev/terraform.tfvars
new file mode 100644
index 0000000..76d3cdd
--- /dev/null
+++ b/src/rtp/env/dev/terraform.tfvars
@@ -0,0 +1,16 @@
+# general
+prefix = "cstar"
+env_short = "d"
+env = "dev"
+domain = "rtp"
+location = "westeurope"
+location_short = "weu"
+
+tags = {
+ CreatedBy = "Terraform"
+ Environment = "DEV"
+ Owner = "CSTAR"
+ Source = "https://github.com/pagopa/cstar-infrastructure"
+ CostCenter = "TS310 - PAGAMENTI & SERVIZI"
+ Application = "RTP"
+}
diff --git a/src/rtp/env/prod/backend.ini b/src/rtp/env/prod/backend.ini
new file mode 100644
index 0000000..18b0a97
--- /dev/null
+++ b/src/rtp/env/prod/backend.ini
@@ -0,0 +1 @@
+subscription=PROD-CSTAR
\ No newline at end of file
diff --git a/src/rtp/env/prod/backend.tfvars b/src/rtp/env/prod/backend.tfvars
new file mode 100644
index 0000000..b377358
--- /dev/null
+++ b/src/rtp/env/prod/backend.tfvars
@@ -0,0 +1,4 @@
+resource_group_name = "io-infra-rg"
+storage_account_name = "cstarinfrastterraform"
+container_name = "azurermstate"
+key = "rtp-apim-product-rtp-prod.terraform.tfstate"
\ No newline at end of file
diff --git a/src/rtp/env/prod/terraform.tfvars b/src/rtp/env/prod/terraform.tfvars
new file mode 100644
index 0000000..9592fb6
--- /dev/null
+++ b/src/rtp/env/prod/terraform.tfvars
@@ -0,0 +1,16 @@
+# general
+prefix = "cstar"
+env_short = "p"
+env = "prod"
+domain = "rtp"
+location = "westeurope"
+location_short = "weu"
+
+tags = {
+ CreatedBy = "Terraform"
+ Environment = "PROD"
+ Owner = "CSTAR"
+ Source = "https://github.com/pagopa/cstar-infrastructure"
+ CostCenter = "TS310 - PAGAMENTI & SERVIZI"
+ Application = "RTP"
+}
diff --git a/src/rtp/env/uat/backend.ini b/src/rtp/env/uat/backend.ini
new file mode 100644
index 0000000..4ec6fba
--- /dev/null
+++ b/src/rtp/env/uat/backend.ini
@@ -0,0 +1 @@
+subscription=UAT-CSTAR
\ No newline at end of file
diff --git a/src/rtp/env/uat/backend.tfvars b/src/rtp/env/uat/backend.tfvars
new file mode 100644
index 0000000..fd35cfa
--- /dev/null
+++ b/src/rtp/env/uat/backend.tfvars
@@ -0,0 +1,4 @@
+resource_group_name = "io-infra-rg"
+storage_account_name = "cstarinfrastterraformuat"
+container_name = "azurermstate"
+key = "rtp-apim-product-rtp-uat.terraform.tfstate"
\ No newline at end of file
diff --git a/src/rtp/env/uat/terraform.tfvars b/src/rtp/env/uat/terraform.tfvars
new file mode 100644
index 0000000..b60828f
--- /dev/null
+++ b/src/rtp/env/uat/terraform.tfvars
@@ -0,0 +1,16 @@
+# general
+prefix = "cstar"
+env_short = "u"
+env = "uat"
+domain = "rtp"
+location = "westeurope"
+location_short = "weu"
+
+tags = {
+ CreatedBy = "Terraform"
+ Environment = "UAT"
+ Owner = "CSTAR"
+ Source = "https://github.com/pagopa/cstar-infrastructure"
+ CostCenter = "TS310 - PAGAMENTI & SERVIZI"
+ Application = "RTP"
+}
diff --git a/src/rtp/terraform.sh b/src/rtp/terraform.sh
new file mode 120000
index 0000000..165ae70
--- /dev/null
+++ b/src/rtp/terraform.sh
@@ -0,0 +1 @@
+../../scripts/terraform.sh
\ No newline at end of file