Skip to content

Commit 1520440

Browse files
committed
feat: polish modules
- Description for variables - Module parity. It would be possible to disable modules (default enabled).
1 parent acf102f commit 1520440

File tree

11 files changed

+132
-27
lines changed

11 files changed

+132
-27
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,50 @@
22

33
Terraform module to integrate Azure as a meshPlatform into meshStack instance.
44

5+
With this module, service principals used by meshStack are created with the required permissions.
6+
7+
# Usage
8+
```hcl
9+
module "meshplatform" {
10+
source = "git@github.com:meshcloud/terraform-azure-meshplatform.git"
11+
12+
spp_name_suffix = "unique-name"
13+
mgmt_group_name = "management-group-name"
14+
}
15+
```
16+
This will create kraken, replicator and idplookup service principals.
17+
18+
If UAMI blueprint user principal is required, you also need to pass a list of subscriptions this user will be assigned to.
19+
20+
example:
21+
```hcl
22+
module "meshplatform" {
23+
source = "git@github.com:meshcloud/terraform-azure-meshplatform.git"
24+
25+
spp_name_suffix = "unique-name"
26+
mgmt_group_name = "management-group-name"
27+
28+
subscriptions = [
29+
"abcdefgh-abcd-efgh-abcd-abcdefgh1234"
30+
, "abcdefgh-abcd-efgh-abcd-abcdefgh5678"
31+
, ...
32+
]
33+
}
34+
```
35+
36+
By default, kraken, replicator, and idplookup service principals are enabled and will be created. To disable a service principal, set its according flag to `false`.
37+
38+
e.g.:
39+
40+
```hcl
41+
module "meshplatform" {
42+
source = "git@github.com:meshcloud/terraform-azure-meshplatform.git"
43+
44+
spp_name_suffix = "unique-name"
45+
mgmt_group_name = "management-group-name"
46+
47+
replicator_enabled = false
48+
kraken_enabled = false
49+
idplookup_enabled = false
50+
}
51+
```

main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ provider "azurerm" {
1414
}
1515

1616
data "azurerm_management_group" "root" {
17-
name = var.mgmt_group_id
17+
name = var.mgmt_group_name
1818
}
1919

2020
module "replicator_spp" {
21+
count = var.replicator_enabled ? 1 : 0
2122
source = "./modules/meshcloud-replicator-spp/"
2223

2324
spp_name_suffix = var.spp_name_suffix
@@ -28,15 +29,25 @@ module "replicator_spp" {
2829
}
2930

3031
module "kraken_spp" {
32+
count = var.kraken_enabled ? 1 : 0
3133
source = "./modules/meshcloud-kraken-spp/"
3234

3335
spp_name_suffix = var.spp_name_suffix
3436
scope = data.azurerm_management_group.root.id
3537
}
3638

3739
module "idp_lookup_spp" {
40+
count = var.idplookup_enabled ? 1 : 0
3841
source = "./modules/meshcloud-idp-lookup-spp/"
3942

4043
spp_name_suffix = var.spp_name_suffix
4144
scope = data.azurerm_management_group.root.id
4245
}
46+
47+
module "uami_blueprint_user_principal" {
48+
count = length(var.subscriptions)
49+
source = "./modules/uami-blueprint-user-principal/"
50+
51+
spp_name_suffix = var.spp_name_suffix
52+
subscriptions = var.subscriptions
53+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This modules creates an Azure Service Principal (Azure SPP) that is used by meshStack for User lookups in AAD IDP.
1+
This module creates an Azure Service Principal (Azure SPP) that is used by meshStack for User lookups in AAD IDP.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This modules creates an Azure Service Principal (Azure SPP) that is used by meshStack to import metering data from Azure.
1+
This module creates an Azure Service Principal (Azure SPP) that is used by meshStack to import metering data from Azure.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This modules creates an Azure Service Principal (Azure SPP) that is used by meshStack for replication.
1+
This module creates an Azure Service Principal (Azure SPP) that is used by meshStack for replication.

modules/meshcloud-replicator-spp/variables.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ variable "scope" {
1010

1111
variable "additional_required_resource_accesses" {
1212
type = list(object({ resource_app_id = string, resource_accesses = list(object({ id = string, type = string })) }))
13+
default = []
1314
description = "Additional AAD-Level Resource Accesses the customer needs"
1415
}
1516

1617
variable "additional_permissions" {
1718
type = list(string)
19+
default = []
1820
description = "Additional Subscription-Level Permissions that the SPP needs"
19-
}
21+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This modules creates an Azure Service Principal (Azure SPP) that is used by meshStack for UAMI blueprint assignment.
1+
This module creates an Azure Service Principal (Azure SPP) that is used by meshStack for UAMI blueprint assignment.

modules/uami-blueprint-user-principal/outputs.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ output "service_principal" {
22
value = {
33
object_id = azuread_service_principal.uami_blueprint_principal.id
44
app_id = azuread_service_principal.uami_blueprint_principal.application_id
5-
password = random_password.spp_pw.result
5+
password = "Execute `terraform output replicator_spp_password` to see the password"
66
}
77
}
8+
9+
output "service_principal_password" {
10+
value = {
11+
password = random_password.spp_pw.result
12+
}
13+
sensitive = true
14+
}

modules/uami-blueprint-user-principal/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ variable "spp_name_suffix" {
44
}
55

66
variable "subscriptions" {
7-
type = list(any)
7+
type = list(any)
8+
description = "The scope to which UAMI blueprint service principal role assignment is applied."
89
}

outputs.tf

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,60 @@
11

22
output "replicator_spp" {
3-
description = "Password for the Service Principal."
3+
description = "Replicator Service Principal."
44
value = {
5-
output = module.replicator_spp.service_principal
5+
output = length(module.replicator_spp) > 0 ? module.replicator_spp[0].service_principal : null
66
}
77
}
88

99
output "replicator_spp_password" {
10-
description = "Password for the Service Principal."
10+
description = "Password for Replicator Service Principal."
1111
value = {
12-
password = module.replicator_spp.service_principal_password
12+
password = length(module.replicator_spp) > 0 ? module.replicator_spp[0].service_principal_password : null
1313
}
1414
sensitive = true
1515
}
1616

1717
output "kraken_spp" {
18-
description = "Password for the Service Principal."
18+
description = "Kraken Service Principal."
1919
value = {
20-
output = module.kraken_spp.service_principal
20+
output = length(module.kraken_spp) > 0 ? module.kraken_spp[0].service_principal : null
2121
}
2222
}
2323

2424
output "kraken_spp_password" {
25-
description = "Password for the Service Principal."
25+
description = "Password for Kraken Service Principal."
2626
value = {
27-
password = module.kraken_spp.service_principal_password
27+
password = length(module.kraken_spp) > 0 ? module.kraken_spp[0].service_principal_password : null
2828
}
2929
sensitive = true
3030
}
3131

3232
output "idp_lookup_spp" {
33-
description = "Password for the Service Principal."
33+
description = "IDP Lookup Service Principal."
3434
value = {
35-
output = module.idp_lookup_spp.service_principal
35+
output = length(module.idp_lookup_spp) > 0 ? module.idp_lookup_spp[0].service_principal : null
3636
}
3737
}
3838

3939
output "idp_lookup_spp_password" {
40-
description = "Password for the Service Principal."
40+
description = "Password for IDP Lookup Service Principal."
4141
value = {
42-
password = module.idp_lookup_spp.service_principal_password
42+
password = length(module.idp_lookup_spp) > 0 ? module.idp_lookup_spp[0].service_principal_password : null
4343
}
4444
sensitive = true
45-
}
45+
}
46+
47+
output "uami_blueprint_user_principal" {
48+
description = "UAMI Blueprint Assignment Service Principal."
49+
value = {
50+
output = length(module.uami_blueprint_user_principal) > 0 ? module.uami_blueprint_user_principal[0].service_principal : null
51+
}
52+
}
53+
54+
output "uami_blueprint_user_principal_password" {
55+
description = "Password for UAMI Blueprint Assignment Service Principal."
56+
value = {
57+
password = length(module.uami_blueprint_user_principal) > 0 ? module.uami_blueprint_user_principal[0].service_principal_password : null
58+
}
59+
sensitive = true
60+
}

0 commit comments

Comments
 (0)