Skip to content

Commit a5748a2

Browse files
committed
fix: remove dynamic user membership type for au
When using Dynamic User as membership type for an Administrative Unit, it is not possible anymore to add groups to the AU. We therefore use the default "assigned" membership type.
1 parent 20d9691 commit a5748a2

File tree

7 files changed

+12
-84
lines changed

7 files changed

+12
-84
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [v0.13.1]
11+
12+
### Changed
13+
14+
- Remove administrative unit membership rule input
15+
- Remove some permissions that are not needed when using administrative units
16+
1017
## [v0.13.0]
1118

1219
### Added
@@ -105,7 +112,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
105112

106113
- Initial Release
107114

108-
[unreleased]: https://github.com/meshcloud/terraform-azure-meshplatform/compare/v0.13.0...HEAD
115+
[unreleased]: https://github.com/meshcloud/terraform-azure-meshplatform/compare/v0.13.1...HEAD
116+
[v0.13.1]: https://github.com/meshcloud/terraform-azure-meshplatform/releases/tag/v0.13.1
109117
[v0.13.0]: https://github.com/meshcloud/terraform-azure-meshplatform/releases/tag/v0.13.0
110118
[v0.12.0]: https://github.com/meshcloud/terraform-azure-meshplatform/releases/tag/v0.12.0
111119
[v0.11.0]: https://github.com/meshcloud/terraform-azure-meshplatform/releases/tag/v0.11.0

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,13 @@ Please include the following `additional_permission` when configuring this terra
119119

120120
### Using Azure Administrative Units
121121

122-
To use Azure Administrative Units with this module, you can set the `administrative_unit_name` and `administrative_unit_membership_rule` variables.
122+
To use Azure Administrative Units with this module, you can set the `administrative_unit_name` variable.
123123

124124
```hcl
125125
module "meshplatform" {
126126
source = "meshcloud/meshplatform/azure"
127127
# required inputs
128128
administrative_unit_name = "my-administrative-unit"
129-
administrative_unit_membership_rule = "(user.accountEnabled -eq true)" # Include all active users
130129
}
131130
```
132131

@@ -248,7 +247,6 @@ Before opening a Pull Request, please do the following:
248247
|------|-------------|------|---------|:--------:|
249248
| <a name="input_additional_permissions"></a> [additional\_permissions](#input\_additional\_permissions) | Additional Subscription-Level Permissions the Service Principal needs. | `list(string)` | `[]` | no |
250249
| <a name="input_additional_required_resource_accesses"></a> [additional\_required\_resource\_accesses](#input\_additional\_required\_resource\_accesses) | Additional AAD-Level Resource Accesses the replicator Service Principal needs. | `list(object({ resource_app_id = string, resource_accesses = list(object({ id = string, type = string })) }))` | `[]` | no |
251-
| <a name="input_administrative_unit_membership_rule"></a> [administrative\_unit\_membership\_rule](#input\_administrative\_unit\_membership\_rule) | Dynamic membership rule for the Administrative Unit. Required when administrative\_unit\_name is set.<br><br>Suggested default: "(user.accountEnabled -eq true)"<br>NOTE: This rule will include ALL active users in your tenant. Consider more restrictive rules for production use.<br><br>Examples for more restrictive rules:<br>- "(user.companyName -eq \"MyCompany\") and (user.accountEnabled -eq true)" - Active users from specific company<br>- "(user.userType -eq \"Member\") and (user.accountEnabled -eq true)" - Active member users only<br><br>For more information on membership rules, see:<br>https://learn.microsoft.com/en-us/entra/identity/users/groups-dynamic-membership | `string` | `null` | no |
252250
| <a name="input_administrative_unit_name"></a> [administrative\_unit\_name](#input\_administrative\_unit\_name) | Display name of the adminstration-unit name where the user groups are managed. | `string` | `null` | no |
253251
| <a name="input_application_owners"></a> [application\_owners](#input\_application\_owners) | List of user principals that should be added as owners to the created service principals. | `list(string)` | `[]` | no |
254252
| <a name="input_can_cancel_subscriptions_in_scopes"></a> [can\_cancel\_subscriptions\_in\_scopes](#input\_can\_cancel\_subscriptions\_in\_scopes) | The scopes to which Service Principal cancel subscription permission is assigned to. List of management group id of form `/providers/Microsoft.Management/managementGroups/<mgmtGroupId>/`. | `list(string)` | `[]` | no |

main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ module "replicator_service_principal" {
6262
can_cancel_subscriptions_in_scopes = var.can_cancel_subscriptions_in_scopes
6363
can_delete_rgs_in_scopes = var.can_delete_rgs_in_scopes
6464

65-
administrative_unit_name = var.administrative_unit_name
66-
administrative_unit_membership_rule = var.administrative_unit_membership_rule
65+
administrative_unit_name = var.administrative_unit_name
6766

6867
additional_required_resource_accesses = var.additional_required_resource_accesses
6968
additional_permissions = var.additional_permissions

modules/meshcloud-replicator-service-principal/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ No modules.
3535
| [azurerm_role_definition.meshcloud_replicator_rg_deleter](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_definition) | resource |
3636
| [azurerm_role_definition.meshcloud_replicator_subscription_canceler](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_definition) | resource |
3737
| [terraform_data.allowed_assignments](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
38-
| [terraform_data.patch_admin_unit](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
3938
| [time_rotating.replicator_secret_rotation](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/rotating) | resource |
4039
| [azuread_application_published_app_ids.well_known](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/application_published_app_ids) | data source |
4140
| [azuread_application_template.enterprise_app](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/application_template) | data source |
@@ -47,7 +46,6 @@ No modules.
4746
|------|-------------|------|---------|:--------:|
4847
| <a name="input_additional_permissions"></a> [additional\_permissions](#input\_additional\_permissions) | Additional Subscription-Level Permissions the Service Principal needs. | `list(string)` | `[]` | no |
4948
| <a name="input_additional_required_resource_accesses"></a> [additional\_required\_resource\_accesses](#input\_additional\_required\_resource\_accesses) | Additional AAD-Level Resource Accesses the Service Principal needs. | `list(object({ resource_app_id = string, resource_accesses = list(object({ id = string, type = string })) }))` | `[]` | no |
50-
| <a name="input_administrative_unit_membership_rule"></a> [administrative\_unit\_membership\_rule](#input\_administrative\_unit\_membership\_rule) | Dynamic membership rule for the Administrative Unit. Required when administrative\_unit\_name is set.<br><br>Suggested default: "(user.accountEnabled -eq true)"<br>NOTE: This rule will include ALL active users in your tenant. Consider more restrictive rules for production use.<br><br>Examples for more restrictive rules:<br>- "(user.companyName -eq \"MyCompany\") and (user.accountEnabled -eq true)" - Active users from specific company<br>- "(user.userType -eq \"Member\") and (user.accountEnabled -eq true)" - Active member users only<br><br>For more information on membership rules, see:<br>https://learn.microsoft.com/en-us/entra/identity/users/groups-dynamic-membership | `string` | `null` | no |
5149
| <a name="input_administrative_unit_name"></a> [administrative\_unit\_name](#input\_administrative\_unit\_name) | Display name of the adminstration-unit name where the user groups are managed. | `string` | `null` | no |
5250
| <a name="input_application_owners"></a> [application\_owners](#input\_application\_owners) | List of user principals that should be added as owners to the replicator service principal. | `list(string)` | `[]` | no |
5351
| <a name="input_assignment_scopes"></a> [assignment\_scopes](#input\_assignment\_scopes) | The scopes to which Service Principal permissions is assigned to. List of management group id of form `/providers/Microsoft.Management/managementGroups/<mgmtGroupId>/`. | `list(string)` | n/a | yes |

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

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -310,42 +310,6 @@ resource "azuread_administrative_unit" "meshcloud_replicator_au" {
310310
display_name = var.administrative_unit_name
311311
}
312312

313-
//--------------------------------------------------------------------------
314-
// Update AU properties via Microsoft Graph API using az rest
315-
//--------------------------------------------------------------------------
316-
317-
resource "terraform_data" "patch_admin_unit" {
318-
count = var.administrative_unit_name == null ? 0 : 1
319-
320-
lifecycle {
321-
precondition {
322-
condition = var.administrative_unit_membership_rule != null
323-
error_message = "When administrative_unit_name is set, administrative_unit_membership_rule must also be provided. Suggested value: \"(user.accountEnabled -eq true)\""
324-
}
325-
}
326-
327-
provisioner "local-exec" {
328-
command = <<-EOT
329-
az rest \
330-
--method PATCH \
331-
--url "https://graph.microsoft.com/v1.0/directory/administrativeUnits/${azuread_administrative_unit.meshcloud_replicator_au[0].object_id}" \
332-
--body '{
333-
"displayName": "${var.administrative_unit_name}",
334-
"membershipType": "Dynamic",
335-
"membershipRule": "${var.administrative_unit_membership_rule}",
336-
"membershipRuleProcessingState": "On"
337-
}'
338-
EOT
339-
}
340-
341-
triggers_replace = {
342-
au_id = azuread_administrative_unit.meshcloud_replicator_au[0].object_id
343-
display_name = var.administrative_unit_name
344-
membership_rule = var.administrative_unit_membership_rule
345-
}
346-
347-
depends_on = [azuread_administrative_unit.meshcloud_replicator_au]
348-
}
349313
//--------------------------------------------------------------------------
350314
// Custom AU-scoped Role
351315
//--------------------------------------------------------------------------
@@ -361,13 +325,11 @@ resource "azuread_custom_directory_role" "meshcloud_replicator_au_role" {
361325
permissions {
362326
allowed_resource_actions = [
363327
"microsoft.directory/users/standard/read",
364-
"microsoft.directory/groups/create",
365328
"microsoft.directory/groups/standard/read",
329+
"microsoft.directory/groups/create",
366330
"microsoft.directory/groups/members/update",
367331
"microsoft.directory/groups/members/read",
368332
"microsoft.directory/groups/memberOf/read",
369-
"microsoft.directory/administrativeUnits/members/read",
370-
"microsoft.directory/administrativeUnits/members/update",
371333
]
372334
}
373335
}

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,3 @@ variable "application_owners" {
6565
description = "List of user principals that should be added as owners to the replicator service principal."
6666
default = []
6767
}
68-
69-
variable "administrative_unit_membership_rule" {
70-
type = string
71-
default = null
72-
description = <<-EOT
73-
Dynamic membership rule for the Administrative Unit. Required when administrative_unit_name is set.
74-
75-
Suggested default: "(user.accountEnabled -eq true)"
76-
NOTE: This rule will include ALL active users in your tenant. Consider more restrictive rules for production use.
77-
78-
Examples for more restrictive rules:
79-
- "(user.companyName -eq \"MyCompany\") and (user.accountEnabled -eq true)" - Active users from specific company
80-
- "(user.userType -eq \"Member\") and (user.accountEnabled -eq true)" - Active member users only
81-
82-
For more information on membership rules, see:
83-
https://learn.microsoft.com/en-us/entra/identity/users/groups-dynamic-membership
84-
EOT
85-
}

variables.tf

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,6 @@ variable "administrative_unit_name" {
4444
default = null
4545
}
4646

47-
variable "administrative_unit_membership_rule" {
48-
type = string
49-
default = null
50-
description = <<-EOT
51-
Dynamic membership rule for the Administrative Unit. Required when administrative_unit_name is set.
52-
53-
Suggested default: "(user.accountEnabled -eq true)"
54-
NOTE: This rule will include ALL active users in your tenant. Consider more restrictive rules for production use.
55-
56-
Examples for more restrictive rules:
57-
- "(user.companyName -eq \"MyCompany\") and (user.accountEnabled -eq true)" - Active users from specific company
58-
- "(user.userType -eq \"Member\") and (user.accountEnabled -eq true)" - Active member users only
59-
60-
For more information on membership rules, see:
61-
https://learn.microsoft.com/en-us/entra/identity/users/groups-dynamic-membership
62-
EOT
63-
}
64-
65-
6647
# SSO inputs
6748

6849
variable "sso_enabled" {

0 commit comments

Comments
 (0)