Skip to content

Commit 0945c10

Browse files
bickmeckmalhussan
authored andcommitted
add owners to applications and service principals
1 parent d066ff5 commit 0945c10

File tree

10 files changed

+46
-0
lines changed

10 files changed

+46
-0
lines changed

main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ module "replicator_service_principal" {
6969
issuer = var.workload_identity_federation.issuer,
7070
subject = var.workload_identity_federation.replicator_subject
7171
}
72+
73+
application_owners = var.application_owners
7274
}
7375

7476
module "mca_service_principal" {
@@ -80,6 +82,8 @@ module "mca_service_principal" {
8082
billing_account_name = var.mca.billing_account_name
8183
billing_profile_name = var.mca.billing_profile_name
8284
invoice_section_name = var.mca.invoice_section_name
85+
86+
application_owners = var.application_owners
8387
}
8488

8589
module "metering_service_principal" {
@@ -94,6 +98,8 @@ module "metering_service_principal" {
9498
issuer = var.workload_identity_federation.issuer,
9599
subject = var.workload_identity_federation.kraken_subject
96100
}
101+
102+
application_owners = var.application_owners
97103
}
98104

99105
module "sso_service_principal" {
@@ -104,6 +110,8 @@ module "sso_service_principal" {
104110
meshstack_idp_domain = var.sso_meshstack_idp_domain
105111
identity_provider_alias = var.sso_identity_provider_alias
106112
app_role_assignment_required = var.sso_app_role_assignment_required
113+
114+
application_owners = var.application_owners
107115
}
108116

109117
# facilitate migration from v0.1.0 of the module

modules/meshcloud-mca-service-principal/module.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ data "azurerm_billing_mca_account_scope" "mca" {
3030
resource "azuread_application" "mca" {
3131
for_each = toset(var.service_principal_names)
3232
display_name = each.key
33+
owners = var.application_owners
3334
}
3435

3536
resource "azuread_service_principal" "mca" {
3637
for_each = toset(var.service_principal_names)
3738
client_id = azuread_application.mca[each.key].client_id
39+
owners = var.application_owners
3840
}
3941

4042
data "azapi_resource_list" "billing_role_definitions" {

modules/meshcloud-mca-service-principal/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ variable "billing_profile_name" {
1313
variable "invoice_section_name" {
1414
type = string
1515
}
16+
17+
variable "application_owners" {
18+
type = list(string)
19+
description = "List of user principals that should be added as owners to the mca service principal."
20+
default = []
21+
}

modules/meshcloud-metering-service-principal/module.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ resource "azurerm_role_assignment" "meshcloud_metering" {
3232
//---------------------------------------------------------------------------
3333
resource "azuread_application" "meshcloud_metering" {
3434
display_name = var.service_principal_name
35+
owners = var.application_owners
3536

3637
feature_tags {
3738
enterprise = true
@@ -50,6 +51,7 @@ resource "azuread_application" "meshcloud_metering" {
5051
//---------------------------------------------------------------------------
5152
resource "azuread_service_principal" "meshcloud_metering" {
5253
client_id = azuread_application.meshcloud_metering.client_id
54+
owners = var.application_owners
5355
feature_tags {
5456
enterprise = true
5557
}

modules/meshcloud-metering-service-principal/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ variable "workload_identity_federation" {
1818
description = "Enable workload identity federation instead of using a password by providing these additional settings. Usually you should receive the required settings when attempting to configure a platform with workload identity federation in meshStack."
1919
type = object({ issuer = string, subject = string })
2020
}
21+
22+
variable "application_owners" {
23+
type = list(string)
24+
description = "List of user principals that should be added as owners to the metering service principal."
25+
default = []
26+
}

modules/meshcloud-replicator-service-principal/module.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ data "azuread_application_template" "enterprise_app" {
116116
}
117117
resource "azuread_application" "meshcloud_replicator" {
118118
display_name = var.service_principal_name
119+
owners = var.application_owners
119120
template_id = data.azuread_application_template.enterprise_app.template_id
120121
feature_tags {
121122
enterprise = true
@@ -168,6 +169,7 @@ resource "azuread_application" "meshcloud_replicator" {
168169
//---------------------------------------------------------------------------
169170
resource "azuread_service_principal" "meshcloud_replicator" {
170171
client_id = azuread_application.meshcloud_replicator.client_id
172+
owners = var.application_owners
171173
feature_tags {
172174
enterprise = true
173175
}

modules/meshcloud-replicator-service-principal/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ variable "workload_identity_federation" {
5353
description = "Enable workload identity federation instead of using a password by providing these additional settings. Usually you should receive the required settings when attempting to configure a platform with workload identity federation in meshStack."
5454
type = object({ issuer = string, subject = string })
5555
}
56+
57+
variable "application_owners" {
58+
type = list(string)
59+
description = "List of user principals that should be added as owners to the replicator service principal."
60+
default = []
61+
}

modules/meshcloud-sso/module.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ data "azuread_application_template" "enterprise_app" {
2929

3030
resource "azuread_application" "meshcloud_sso" {
3131
display_name = var.service_principal_name
32+
owners = var.application_owners
3233
template_id = data.azuread_application_template.enterprise_app.template_id
3334
feature_tags {
3435
enterprise = true
@@ -54,6 +55,7 @@ resource "azuread_service_principal" "meshcloud_sso" {
5455
use_existing = true
5556
app_role_assignment_required = var.app_role_assignment_required
5657
client_id = azuread_application.meshcloud_sso.client_id
58+
owners = var.application_owners
5759
}
5860

5961
resource "azuread_application_password" "meshcloud_sso" {

modules/meshcloud-sso/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ variable "app_role_assignment_required" {
2020
default = false
2121
description = "Whether all users can login using the created application (false), or only assigned users (true)"
2222
}
23+
24+
variable "application_owners" {
25+
type = list(string)
26+
description = "List of user principals that should be added as owners to the sso service principal."
27+
default = []
28+
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,9 @@ variable "mca" {
123123
})
124124
default = null
125125
}
126+
127+
variable "application_owners" {
128+
type = list(string)
129+
description = "List of user principals that should be added as owners to the created service principals."
130+
default = []
131+
}

0 commit comments

Comments
 (0)