Skip to content

Commit f8ee414

Browse files
authored
Merge c8b43c9 into ad5c238
2 parents ad5c238 + c8b43c9 commit f8ee414

File tree

7 files changed

+23
-4
lines changed

7 files changed

+23
-4
lines changed

azure-pipelines/cd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pool:
1919

2020
variables:
2121
- template: vars/global.yaml
22+
- group: mask-ids
2223

2324
# Conditional uses ${{ }} syntax in order to be processed at compile time
2425
# in order to work for loading variable groups. For details see:

azure-pipelines/pr-main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pr:
1111
variables:
1212
- template: vars/global.yaml
1313
- group: e2e-gov-demo-dev-kv # DEV
14+
- group: mask-ids
1415

1516
stages:
1617
- template: stages/ci.yaml

azure-pipelines/pr-production.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pr:
1111
variables:
1212
- template: vars/global.yaml
1313
- group: e2e-gov-demo-kv # PROD
14+
- group: mask-ids
1415

1516
stages:
1617
- template: stages/ci.yaml

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ resource "random_string" "suffix" {
1313
}
1414

1515
locals {
16-
suffix = random_string.suffix.result
17-
18-
# Default to current ARM client
19-
superadmins_aad_object_id = var.superadmins_aad_object_id == "" ? data.azurerm_client_config.current.object_id : var.superadmins_aad_object_id
16+
suffix = random_string.suffix.result
17+
application_owners_ids = length(var.application_owners_ids) == 0 ? [data.azurerm_client_config.current.object_id] : var.application_owners_ids
18+
superadmins_aad_object_id = var.superadmins_aad_object_id == "" ? data.azurerm_client_config.current.object_id : var.superadmins_aad_object_id # Default to current ARM client
2019
}
2120

2221
# ---------------
@@ -40,6 +39,7 @@ module "service_principals" {
4039
for_each = var.environments
4140
source = "./modules/service-principal"
4241
name = "${each.value.team}-${each.value.env}-${local.suffix}-ci-sp"
42+
owners = local.application_owners_ids
4343
}
4444

4545
# ------------------------------

modules/service-principal/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
resource "azuread_application" "app" {
66
display_name = local.name
7+
owners = var.owners
78
}
89

910
resource "azuread_application_password" "workspace_sp_secret" {

modules/service-principal/variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ variable "password_lifetime" {
2323
default = "4380h"
2424
}
2525

26+
variable "owners" {
27+
type = list(string)
28+
description = "A set of object IDs of principals that will be granted ownership of the application (service principal)."
29+
validation {
30+
condition = length(var.owners) > 0
31+
error_message = "Every Application must have an owner. Owners cannot be empty."
32+
}
33+
}
34+
2635
# Normalize Values
2736
# ----------------
2837

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ variable "superadmins_aad_object_id" {
55
default = ""
66
}
77

8+
variable "application_owners_ids" {
9+
type = list(string)
10+
description = "A set of object IDs of principals that will be granted ownership of the application (service principal). Supported object types are users or service principals. It is best practice to specify one or more owners, incl. the principal used to execute Terraform"
11+
default = []
12+
}
13+
814
# AAD Groups
915
variable "groups" {
1016
type = map(string)

0 commit comments

Comments
 (0)