Skip to content

Commit 592ec10

Browse files
feat: IDH modules tests (#157)
* upgrated to v4 modules * terraform script updated * minor fix * first try * fixed idh modules * pre-commit fixs * updated provider to avoid errors * pre-commit fixs
1 parent b04775d commit 592ec10

File tree

10 files changed

+226
-124
lines changed

10 files changed

+226
-124
lines changed

src/10_networking/env/dev/terraform.tfvars

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ cidr_subnet_apim_stv2 = ["10.1.152.0/24"]
4646
### Italy
4747
cidr_vnet_italy = ["10.3.0.0/16"]
4848

49-
cidr_subnet_vpn = ["10.3.2.0/24"]
49+
cidr_subnet_vpn = ["10.3.2.0/24"]
5050

5151
cidr_subnet_dnsforwarder_lb = ["10.3.200.0/29"]
5252
cidr_subnet_dnsforwarder_vmss = ["10.3.200.8/29"]
@@ -63,5 +63,3 @@ vpn_pip_sku = "Standard"
6363

6464

6565
dns_forwarder_vmss_image_version = "v20250214"
66-
67-

src/domains/testit-common/.terraform.lock.hcl

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

src/domains/testit-common/01_keyvault_0.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resource "azurerm_resource_group" "sec_rg_domain" {
66
}
77

88
module "key_vault_domain" {
9-
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//key_vault?ref=v8.13.0"
9+
source = "./.terraform/modules/__v4__/key_vault"
1010

1111
name = "${local.project}-kv"
1212
location = azurerm_resource_group.sec_rg_domain.location

src/domains/testit-common/02_workload_identity.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "workload_identity_init" {
2-
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//kubernetes_workload_identity_init?ref=v8.42.1"
2+
source = "./.terraform/modules/__v4__/kubernetes_workload_identity_init"
33

44
workload_identity_name_prefix = var.domain
55
workload_identity_resource_group_name = data.azurerm_kubernetes_cluster.aks.resource_group_name

src/domains/testit-common/10_github_identity.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ locals {
4242

4343
# create a module for each 20 repos
4444
module "identity_cd_01" {
45-
source = "github.com/pagopa/terraform-azurerm-v3//github_federated_identity?ref=v8.13.0"
45+
source = "./.terraform/modules/__v4__/github_federated_identity"
4646
# pagopa-<ENV><DOMAIN>-<COUNTER>-github-<PERMS>-identity
4747
prefix = var.prefix
4848
env_short = var.env_short
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
resource "azurerm_resource_group" "idh_rg" {
2+
location = var.location
3+
name = "${local.project}-idh-rg"
4+
}
5+
6+
7+
module "cosmosdb_account" {
8+
count = local.idh_enabled ? 1 : 0
9+
source = "./.terraform/modules/__v4__/IDH/cosmosdb_account"
10+
11+
domain = var.domain
12+
name = "${local.project}-idh-cosmos-account"
13+
resource_group_name = azurerm_resource_group.idh_rg.name
14+
location = var.location
15+
main_geo_location_location = var.location
16+
product_name = "dvopla"
17+
env = "dev"
18+
idh_resource_tier = "cosmos_mongo6"
19+
tags = {}
20+
}
21+
22+
23+
module "event_hub" {
24+
count = local.idh_enabled ? 1 : 0
25+
source = "./.terraform/modules/__v4__/IDH/event_hub"
26+
27+
name = "${local.project}-idh-evh"
28+
product_name = "dvopla"
29+
env = "dev"
30+
idh_resource_tier = "standard"
31+
location = var.location
32+
resource_group_name = azurerm_resource_group.idh_rg.name
33+
tags = {}
34+
}
35+
36+
37+
module "key_vault" {
38+
count = local.idh_enabled ? 1 : 0
39+
source = "./.terraform/modules/__v4__/IDH/key_vault"
40+
41+
name = "${local.product_ita}-idh-kv"
42+
idh_resource_tier = "standard"
43+
product_name = "dvopla"
44+
env = "dev"
45+
location = var.location
46+
resource_group_name = azurerm_resource_group.idh_rg.name
47+
tenant_id = data.azurerm_client_config.current.tenant_id
48+
tags = {}
49+
}
50+
51+
52+
module "redis" {
53+
count = local.idh_enabled ? 1 : 0
54+
source = "./.terraform/modules/__v4__/IDH/redis"
55+
56+
name = "${local.project}-idh-redis"
57+
product_name = "dvopla"
58+
env = "dev"
59+
idh_resource_tier = "basic"
60+
location = var.location
61+
resource_group_name = azurerm_resource_group.idh_rg.name
62+
tags = {}
63+
}
64+
65+
66+
module "storage_account" {
67+
count = local.idh_enabled ? 1 : 0
68+
source = "./.terraform/modules/__v4__/IDH/storage_account"
69+
70+
name = replace("${local.project}-idh-sa", "-", "")
71+
72+
product_name = "dvopla"
73+
env = "dev"
74+
idh_resource_tier = "basic"
75+
domain = var.domain
76+
location = var.location
77+
resource_group_name = azurerm_resource_group.idh_rg.name
78+
tags = {}
79+
}
80+
81+
module "subnet" {
82+
count = local.idh_enabled ? 1 : 0
83+
source = "./.terraform/modules/__v4__/IDH/subnet"
84+
85+
name = "${local.project}-idh-snet"
86+
resource_group_name = data.azurerm_virtual_network.vnet_ita.resource_group_name
87+
virtual_network_name = data.azurerm_virtual_network.vnet_ita.name
88+
service_endpoints = ["Microsoft.Storage"]
89+
idh_resource_tier = "postgres_flexible"
90+
product_name = "dvopla"
91+
env = "dev"
92+
}
93+
94+
resource "random_password" "postgres_password" {
95+
count = local.idh_enabled ? 1 : 0
96+
length = 20
97+
special = true
98+
min_lower = 3
99+
min_upper = 3
100+
min_numeric = 3
101+
min_special = 3
102+
}
103+
104+
module "postgres_flexible_server" {
105+
count = local.idh_enabled ? 1 : 0
106+
107+
source = "./.terraform/modules/__v4__/IDH/postgres_flexible_server"
108+
109+
name = "${local.project}-idh-flexible"
110+
idh_resource_tier = "pgflex2"
111+
product_name = "dvopla"
112+
env = "dev"
113+
location = var.location
114+
resource_group_name = azurerm_resource_group.idh_rg.name
115+
delegated_subnet_id = module.subnet[0].subnet_id
116+
administrator_login = "adminuser"
117+
administrator_password = random_password.postgres_password[0].result
118+
log_analytics_workspace_id = data.azurerm_log_analytics_workspace.log_analytics.id
119+
tags = {}
120+
}

src/domains/testit-common/99_main.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
terraform {
22
required_providers {
3-
azurerm = {
4-
source = "hashicorp/azurerm"
5-
version = "<= 3.116.0"
6-
}
73
azuread = {
84
source = "hashicorp/azuread"
9-
version = "<= 2.47.0"
5+
version = "~> 3.1"
106
}
11-
null = {
12-
source = "hashicorp/null"
13-
version = "<= 3.2.1"
7+
azurerm = {
8+
source = "hashicorp/azurerm"
9+
version = "<= 4.30"
1410
}
1511
}
1612

@@ -28,3 +24,8 @@ provider "azurerm" {
2824
data "azurerm_subscription" "current" {}
2925

3026
data "azurerm_client_config" "current" {}
27+
28+
module "__v4__" {
29+
# https://github.com/pagopa/terraform-azurerm-v4/releases/tag/v7.0.0
30+
source = "git::https://github.com/pagopa/terraform-azurerm-v4.git?ref=92fa18c908a4d6485f495dcf3a033d1472c98d29"
31+
}

src/domains/testit-common/99_variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ locals {
1818
dns_zone_public_name = "devopslab.pagopa.it"
1919
dns_zone_private_name = "internal.devopslab.pagopa.it"
2020

21+
idh_enabled = false
2122
}
2223

2324
variable "prefix" {

src/domains/testit-common/README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@
33

44
| Name | Version |
55
|------|---------|
6-
| <a name="requirement_azuread"></a> [azuread](#requirement\_azuread) | <= 2.47.0 |
7-
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | <= 3.116.0 |
8-
| <a name="requirement_null"></a> [null](#requirement\_null) | <= 3.2.1 |
6+
| <a name="requirement_azuread"></a> [azuread](#requirement\_azuread) | ~> 3.1 |
7+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | <= 4.30 |
98

109
## Modules
1110

1211
| Name | Source | Version |
1312
|------|--------|---------|
14-
| <a name="module_identity_cd_01"></a> [identity\_cd\_01](#module\_identity\_cd\_01) | github.com/pagopa/terraform-azurerm-v3//github_federated_identity | v8.13.0 |
15-
| <a name="module_key_vault_domain"></a> [key\_vault\_domain](#module\_key\_vault\_domain) | git::https://github.com/pagopa/terraform-azurerm-v3.git//key_vault | v8.13.0 |
16-
| <a name="module_workload_identity_init"></a> [workload\_identity\_init](#module\_workload\_identity\_init) | git::https://github.com/pagopa/terraform-azurerm-v3.git//kubernetes_workload_identity_init | v8.42.1 |
13+
| <a name="module___v4__"></a> [\_\_v4\_\_](#module\_\_\_v4\_\_) | git::https://github.com/pagopa/terraform-azurerm-v4.git | 92fa18c908a4d6485f495dcf3a033d1472c98d29 |
14+
| <a name="module_cosmosdb_account"></a> [cosmosdb\_account](#module\_cosmosdb\_account) | ./.terraform/modules/__v4__/IDH/cosmosdb_account | n/a |
15+
| <a name="module_event_hub"></a> [event\_hub](#module\_event\_hub) | ./.terraform/modules/__v4__/IDH/event_hub | n/a |
16+
| <a name="module_identity_cd_01"></a> [identity\_cd\_01](#module\_identity\_cd\_01) | ./.terraform/modules/__v4__/github_federated_identity | n/a |
17+
| <a name="module_key_vault"></a> [key\_vault](#module\_key\_vault) | ./.terraform/modules/__v4__/IDH/key_vault | n/a |
18+
| <a name="module_key_vault_domain"></a> [key\_vault\_domain](#module\_key\_vault\_domain) | ./.terraform/modules/__v4__/key_vault | n/a |
19+
| <a name="module_postgres_flexible_server"></a> [postgres\_flexible\_server](#module\_postgres\_flexible\_server) | ./.terraform/modules/__v4__/IDH/postgres_flexible_server | n/a |
20+
| <a name="module_redis"></a> [redis](#module\_redis) | ./.terraform/modules/__v4__/IDH/redis | n/a |
21+
| <a name="module_storage_account"></a> [storage\_account](#module\_storage\_account) | ./.terraform/modules/__v4__/IDH/storage_account | n/a |
22+
| <a name="module_subnet"></a> [subnet](#module\_subnet) | ./.terraform/modules/__v4__/IDH/subnet | n/a |
23+
| <a name="module_workload_identity_init"></a> [workload\_identity\_init](#module\_workload\_identity\_init) | ./.terraform/modules/__v4__/kubernetes_workload_identity_init | n/a |
1724

1825
## Resources
1926

@@ -23,8 +30,10 @@
2330
| [azurerm_key_vault_access_policy.adgroup_developers_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
2431
| [azurerm_key_vault_access_policy.adgroup_externals_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
2532
| [azurerm_key_vault_access_policy.gha_iac_managed_identities](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
33+
| [azurerm_resource_group.idh_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
2634
| [azurerm_resource_group.sec_rg_domain](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
2735
| [null_resource.github_runner_app_permissions_to_namespace_cd_01](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
36+
| [random_password.postgres_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
2837
| [azuread_group.adgroup_admin](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) | data source |
2938
| [azuread_group.adgroup_developers](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) | data source |
3039
| [azuread_group.adgroup_externals](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) | data source |

0 commit comments

Comments
 (0)