Skip to content

Commit fc2ad61

Browse files
feat: [PAYMCLOUD-580] Setup Container App Env on Hub-Spoke VNET (#3633)
* cae hub spoke * cruscotto & payopt on new cae * printit
1 parent 307fb89 commit fc2ad61

37 files changed

+293
-317
lines changed

src/core-itn/.terraform.lock.hcl

Lines changed: 27 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core-itn/00_network.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@ data "azurerm_key_vault_secret" "cstar_subscription_id" {
3535
name = "cstar-subscription-id"
3636
key_vault_id = module.key_vault.id
3737
}
38+
39+
### Vnet Hub - Spoke
40+
data "azurerm_virtual_network" "spoke_tools" {
41+
name = "${local.product_ita}-spoke-tools-vnet"
42+
resource_group_name = "${local.product_ita}-network-hub-spoke-rg"
43+
}

src/core-itn/01_network.tf

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
resource "azurerm_resource_group" "rg_ita_vnet" {
55
name = "${local.product_ita}-vnet-rg"
6-
location = var.location_ita
6+
location = var.location
77

88
tags = module.tag_config.tags
99
}
@@ -12,7 +12,7 @@ module "vnet_italy" {
1212
source = "./.terraform/modules/__v4__/virtual_network"
1313
count = 1
1414
name = "${local.product_ita}-vnet"
15-
location = var.location_ita
15+
location = var.location
1616
resource_group_name = azurerm_resource_group.rg_ita_vnet.name
1717

1818
address_space = var.cidr_vnet_italy
@@ -25,7 +25,7 @@ module "vnet_italy" {
2525
module "vnet_integration_cstar" {
2626
source = "./.terraform/modules/__v4__/virtual_network"
2727
name = "${local.product_ita}-cstar-integration-vnet"
28-
location = var.location_ita
28+
location = var.location
2929
resource_group_name = azurerm_resource_group.rg_ita_vnet.name
3030

3131
address_space = var.cidr_vnet_italy_cstar_integration
@@ -169,4 +169,19 @@ module "cstar_integration_private_endpoint_snet" {
169169
name = "${local.product_ita}-private-endpoint-snet"
170170
resource_group_name = azurerm_resource_group.rg_ita_vnet.name
171171
virtual_network_name = module.vnet_integration_cstar.name
172+
173+
tags = module.tag_config.tags
172174
}
175+
176+
module "spoke_subnet_container_app" {
177+
source = "./.terraform/modules/__v4__/IDH/subnet"
178+
179+
env = var.env
180+
idh_resource_tier = "container_app_environment"
181+
name = "${local.project}-spoke-tools-cae-subnet"
182+
product_name = var.prefix
183+
resource_group_name = data.azurerm_virtual_network.spoke_tools.resource_group_name
184+
virtual_network_name = data.azurerm_virtual_network.spoke_tools.name
185+
186+
tags = module.tag_config.tags
187+
}

src/core-itn/90_tools_cae.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,25 @@ resource "azurerm_container_app_environment" "tools_cae" {
2020

2121
tags = module.tag_config.tags
2222
}
23+
24+
resource "azurerm_container_app_environment" "spoke_cae" {
25+
count = var.is_feature_enabled.container_app_tools_cae ? 1 : 0
26+
27+
name = "${local.project}-spoke-tools-cae"
28+
29+
location = azurerm_resource_group.tools_rg[0].location
30+
resource_group_name = azurerm_resource_group.tools_rg[0].name
31+
32+
log_analytics_workspace_id = azurerm_log_analytics_workspace.log_analytics_workspace.id
33+
infrastructure_subnet_id = module.spoke_subnet_container_app.id
34+
internal_load_balancer_enabled = true
35+
public_network_access = "Disabled"
36+
37+
tags = module.tag_config.tags
38+
39+
lifecycle {
40+
ignore_changes = [
41+
infrastructure_resource_group_name
42+
]
43+
}
44+
}

src/core-itn/99_locals.tf

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
locals {
22
product = "${var.prefix}-${var.env_short}"
3-
product_ita = "${var.prefix}-${var.env_short}-${var.location_short_ita}"
4-
project = "${var.prefix}-${var.env_short}-${var.location_short_ita}-${var.domain}"
5-
6-
monitor_appinsights_name = "${local.product}-appinsights"
7-
monitor_action_group_slack_name = "SlackPagoPA"
8-
monitor_action_group_email_name = "PagoPA"
9-
10-
vnet_name = "${var.prefix}-${var.env_short}-${var.location_short}-vnet"
11-
vnet_resource_group_name = "${var.prefix}-${var.env_short}-${var.location_short}-vnet-rg"
3+
product_ita = "${var.prefix}-${var.env_short}-${var.location_short}"
4+
project = "${var.prefix}-${var.env_short}-${var.location_short}-${var.domain}"
125

136
# peerings
147
vnet_core_name = "${local.product}-vnet"

src/core-itn/99_main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ data "azurerm_client_config" "current" {}
4848

4949

5050
module "__v4__" {
51-
# 7.2.0
52-
source = "git::https://github.com/pagopa/terraform-azurerm-v4.git?ref=5c38b6fc6e2aa2c2c3e94be5dd6bb6ee8d690a49"
51+
# 8.4.0
52+
source = "git::https://github.com/pagopa/terraform-azurerm-v4.git?ref=91f7e70706ce328dc819a908d6e953f0b7b0fed3"
5353
}

src/core-itn/99_variables.tf

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,6 @@ variable "location_short" {
5858
description = "One of wue, neu"
5959
}
6060

61-
### Italy location
62-
variable "location_ita" {
63-
type = string
64-
description = "Main location"
65-
default = "italynorth"
66-
}
67-
68-
variable "location_short_ita" {
69-
type = string
70-
validation {
71-
condition = (
72-
length(var.location_short_ita) == 3
73-
)
74-
error_message = "Length must be 3 chars."
75-
}
76-
description = "Location short for italy: itn"
77-
default = "itn"
78-
}
79-
8061
variable "vnet_ita_ddos_protection_plan" {
8162
type = object({
8263
id = string

src/core-itn/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ No outputs.
108108

109109
| Name | Source | Version |
110110
|------|--------|---------|
111-
| <a name="module___v4__"></a> [\_\_v4\_\_](#module\_\_\_v4\_\_) | git::https://github.com/pagopa/terraform-azurerm-v4.git | 5c38b6fc6e2aa2c2c3e94be5dd6bb6ee8d690a49 |
111+
| <a name="module___v4__"></a> [\_\_v4\_\_](#module\_\_\_v4\_\_) | git::https://github.com/pagopa/terraform-azurerm-v4.git | 91f7e70706ce328dc819a908d6e953f0b7b0fed3 |
112112
| <a name="module_common_private_endpoint_snet"></a> [common\_private\_endpoint\_snet](#module\_common\_private\_endpoint\_snet) | ./.terraform/modules/__v4__/subnet | n/a |
113113
| <a name="module_container_registry_ita"></a> [container\_registry\_ita](#module\_container\_registry\_ita) | ./.terraform/modules/__v4__/container_registry | n/a |
114114
| <a name="module_cstar_integration_private_endpoint_snet"></a> [cstar\_integration\_private\_endpoint\_snet](#module\_cstar\_integration\_private\_endpoint\_snet) | ./.terraform/modules/__v4__/IDH/subnet | n/a |
115115
| <a name="module_domain_key_vault_secrets_query"></a> [domain\_key\_vault\_secrets\_query](#module\_domain\_key\_vault\_secrets\_query) | ./.terraform/modules/__v4__/key_vault_secrets_query | n/a |
116116
| <a name="module_key_vault"></a> [key\_vault](#module\_key\_vault) | ./.terraform/modules/__v4__/key_vault | n/a |
117+
| <a name="module_spoke_subnet_container_app"></a> [spoke\_subnet\_container\_app](#module\_spoke\_subnet\_container\_app) | ./.terraform/modules/__v4__/IDH/subnet | n/a |
117118
| <a name="module_tag_config"></a> [tag\_config](#module\_tag\_config) | ../tag_config | n/a |
118119
| <a name="module_vnet_cstar_integration_to_vnet_ita_peering"></a> [vnet\_cstar\_integration\_to\_vnet\_ita\_peering](#module\_vnet\_cstar\_integration\_to\_vnet\_ita\_peering) | ./.terraform/modules/__v4__/virtual_network_peering | n/a |
119120
| <a name="module_vnet_cstar_integration_to_vnet_weu_peering"></a> [vnet\_cstar\_integration\_to\_vnet\_weu\_peering](#module\_vnet\_cstar\_integration\_to\_vnet\_weu\_peering) | ./.terraform/modules/__v4__/virtual_network_peering | n/a |
@@ -127,6 +128,7 @@ No outputs.
127128
| Name | Type |
128129
|------|------|
129130
| [azurerm_application_insights.application_insights](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_insights) | resource |
131+
| [azurerm_container_app_environment.spoke_cae](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_app_environment) | resource |
130132
| [azurerm_container_app_environment.tools_cae](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_app_environment) | resource |
131133
| [azurerm_key_vault_access_policy.ad_group_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
132134
| [azurerm_key_vault_access_policy.adgroup_developers_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
@@ -197,6 +199,7 @@ No outputs.
197199
| [azurerm_resource_group.rg_vnet_integration](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source |
198200
| [azurerm_subscription.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subscription) | data source |
199201
| [azurerm_user_assigned_identity.iac_federated_azdo](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/user_assigned_identity) | data source |
202+
| [azurerm_virtual_network.spoke_tools](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source |
200203
| [azurerm_virtual_network.vnet_core](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source |
201204
| [azurerm_virtual_network.vnet_integration](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source |
202205

@@ -224,9 +227,7 @@ No outputs.
224227
| <a name="input_law_retention_in_days"></a> [law\_retention\_in\_days](#input\_law\_retention\_in\_days) | The workspace data retention in days | `number` | n/a | yes |
225228
| <a name="input_law_sku"></a> [law\_sku](#input\_law\_sku) | Sku of the Log Analytics Workspace | `string` | n/a | yes |
226229
| <a name="input_location"></a> [location](#input\_location) | One of westeurope, northeurope | `string` | n/a | yes |
227-
| <a name="input_location_ita"></a> [location\_ita](#input\_location\_ita) | Main location | `string` | `"italynorth"` | no |
228230
| <a name="input_location_short"></a> [location\_short](#input\_location\_short) | One of wue, neu | `string` | n/a | yes |
229-
| <a name="input_location_short_ita"></a> [location\_short\_ita](#input\_location\_short\_ita) | Location short for italy: itn | `string` | `"itn"` | no |
230231
| <a name="input_log_analytics_workspace_name"></a> [log\_analytics\_workspace\_name](#input\_log\_analytics\_workspace\_name) | Specifies the name of the Log Analytics Workspace. | `string` | n/a | yes |
231232
| <a name="input_log_analytics_workspace_resource_group_name"></a> [log\_analytics\_workspace\_resource\_group\_name](#input\_log\_analytics\_workspace\_resource\_group\_name) | The name of the resource group in which the Log Analytics workspace is located in. | `string` | n/a | yes |
232233
| <a name="input_monitor_resource_group_name"></a> [monitor\_resource\_group\_name](#input\_monitor\_resource\_group\_name) | Monitor resource group name | `string` | n/a | yes |

src/core-itn/env/dev/terraform.tfvars

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
prefix = "pagopa"
2-
env_short = "d"
3-
env = "dev"
4-
domain = "core"
5-
location = "italynorth"
6-
location_short = "itn"
7-
location_ita = "italynorth"
8-
location_short_ita = "itn"
9-
1+
prefix = "pagopa"
2+
env_short = "d"
3+
env = "dev"
4+
domain = "core"
5+
location = "italynorth"
6+
location_short = "itn"
107

118
### Feature Flag
129
is_feature_enabled = {

src/core-itn/env/prod/terraform.tfvars

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
prefix = "pagopa"
2-
env_short = "p"
3-
env = "prod"
4-
domain = "core"
5-
location = "italynorth"
6-
location_short = "itn"
7-
location_ita = "italynorth"
8-
location_short_ita = "itn"
9-
1+
prefix = "pagopa"
2+
env_short = "p"
3+
env = "prod"
4+
domain = "core"
5+
location = "italynorth"
6+
location_short = "itn"
107

118
### Feature Flag
129
is_feature_enabled = {

0 commit comments

Comments
 (0)