Skip to content

Commit 51c444c

Browse files
authored
Remove unecessary entra_id_login variable validation (#87)
Signed-off-by: Roman Schwarz <rs@cloudeteer.de>
1 parent c440da7 commit 51c444c

2 files changed

Lines changed: 37 additions & 21 deletions

File tree

tests/local/input_entra_id.tftest.hcl

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ run "entra_id_extension_and_identity_type_should_be_created" {
88

99
variables {
1010
extensions = []
11+
1112
entra_id_login = {
1213
enabled = true
1314
admin_login_principal_ids = ["00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000001"]
1415
}
15-
1616
}
1717

1818
assert {
@@ -22,23 +22,24 @@ run "entra_id_extension_and_identity_type_should_be_created" {
2222

2323
assert {
2424
condition = local.identity_type == "SystemAssigned"
25-
error_message = "It is not possible to install the EntraID-Extension without setting the Idenity to 'SystemAssigned' OR 'SystemAssigned, UserAssigned'."
25+
error_message = "It is not possible to install the EntraID-Extension without setting the Identity to 'SystemAssigned' OR 'SystemAssigned, UserAssigned'."
2626
}
27-
2827
}
2928

3029
run "entra_id_extension_and_add_identity_type_should_be_created" {
3130
command = plan
3231

3332
variables {
3433
extensions = []
34+
3535
identity = {
36-
type = "UserAssigned" }
36+
type = "UserAssigned"
37+
}
38+
3739
entra_id_login = {
3840
enabled = true
3941
admin_login_principal_ids = ["00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000001"]
4042
}
41-
4243
}
4344

4445
assert {
@@ -48,9 +49,8 @@ run "entra_id_extension_and_add_identity_type_should_be_created" {
4849

4950
assert {
5051
condition = local.identity_type == "SystemAssigned, UserAssigned"
51-
error_message = "It is not possible to install the EntraID-Extension without setting the Idenity to 'SystemAssigned' OR 'SystemAssigned, UserAssigned'."
52+
error_message = "It is not possible to install the EntraID-Extension without setting the Identity to 'SystemAssigned' OR 'SystemAssigned, UserAssigned'."
5253
}
53-
5454
}
5555

5656
run "nothing_should_be_created_regarding_entra_id_login" {
@@ -74,26 +74,53 @@ run "nothing_should_be_created_regarding_entra_id_login" {
7474
condition = local.identity_type == var.identity
7575
error_message = "No identity type should be created when 'entra_id_login' is disabled."
7676
}
77-
7877
}
7978

8079
run "entra_id_extension_and_identity_type_is_given" {
8180
command = plan
8281

8382
variables {
8483
extensions = []
84+
8585
identity = {
86-
type = "SystemAssigned, UserAssigned" }
86+
type = "SystemAssigned, UserAssigned"
87+
}
88+
8789
entra_id_login = {
8890
enabled = true
8991
admin_login_principal_ids = ["00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000001"]
9092
}
91-
9293
}
9394

9495
assert {
9596
condition = local.identity_type == "SystemAssigned, UserAssigned"
9697
error_message = "Keep 'SystemAssigned, UserAssigned' in case of usage."
9798
}
99+
}
100+
101+
run "entra_id_extension_created_without_principal_ids_and_no_role_assignments" {
102+
command = plan
103+
104+
variables {
105+
extensions = []
106+
107+
entra_id_login = {
108+
enabled = true
109+
}
110+
}
98111

112+
assert {
113+
condition = length(azurerm_virtual_machine_extension.entra_id_login) == 1
114+
error_message = "The EntraID extension should be created even if no principal IDs are provided."
115+
}
116+
117+
assert {
118+
condition = length(azurerm_role_assignment.entra_id_login_user) == 0
119+
error_message = "No user role assignments should be created when no principal IDs are provided for EntraID login."
120+
}
121+
122+
assert {
123+
condition = length(azurerm_role_assignment.entra_id_login_admin) == 0
124+
error_message = "No admin role assignments should be created when no principal IDs are provided for EntraID login."
125+
}
99126
}

variables.tf

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -342,17 +342,6 @@ variable "entra_id_login" {
342342
!contains(["Standard_B1ls", "Basic_A0", "Standard_A0"], var.size))
343343
error_message = "Entra ID Extension requires at least 1GB of memory; set var.size to an SKU that meets this requirement."
344344
}
345-
346-
validation {
347-
condition = anytrue([
348-
!var.entra_id_login.enabled,
349-
length(var.entra_id_login.principal_ids) > 0,
350-
length(var.entra_id_login.admin_login_principal_ids) > 0,
351-
length(var.entra_id_login.user_login_principal_ids) > 0
352-
])
353-
error_message = "When 'entra_id_login.enabled' is 'true', 'admin_login_principal_ids' or 'user_login_principal_ids' must contain at least one valid principal ID."
354-
}
355-
356345
}
357346

358347
variable "extensions" {

0 commit comments

Comments
 (0)