generated from Azure/terraform-azurerm-avm-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
variables.managedidentities.tf
33 lines (29 loc) · 1.48 KB
/
variables.managedidentities.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
variable "managed_identities" {
type = object({
system_assigned = optional(bool, false)
user_assigned_resource_ids = optional(set(string), [])
})
default = {}
nullable = false
description = <<DESCRIPTION
Defaults to `{}`. Controls the Managed Identity configuration on this resource. The following properties can be specified:
- `system_assigned` - (Optional) - Defaults to `false`. Specifies if the System Assigned Managed Identity should be enabled.
- `user_assigned_resource_ids` - (Optional) - Defaults to `[]`. Specifies a set of User Assigned Managed Identity resource IDs to be assigned to this resource.
Example Inputs:
```hcl
managed_identities = {
system_assigned = true
user_assigned_resource_ids = [
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managedIdentityName}"
]
}
```
DESCRIPTION
validation {
condition = alltrue([
for mi_id in var.managed_identities.user_assigned_resource_ids :
can(regex("^/subscriptions/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/resourceGroups/.+/providers/Microsoft.ManagedIdentity/userAssignedIdentities/.+$", mi_id))
])
error_message = "'user_assigned_resource_ids' must be in the format '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managedIdentityName}'"
}
}