-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathvariables.tf
More file actions
199 lines (179 loc) · 8.01 KB
/
variables.tf
File metadata and controls
199 lines (179 loc) · 8.01 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
variable "location" {
type = string
description = "Required. The Azure region for deployment of the this resource."
nullable = false
}
variable "name" {
type = string
description = "Required. The name of the this resource."
validation {
condition = can(regex("^[a-zA-Z0-9_().-]{1,89}[a-zA-Z0-9_()-]$", var.name))
error_message = <<ERROR_MESSAGE
The resource group name must meet the following requirements:
- `Between 1 and 90 characters long.`
- `Can only contain Alphanumerics, underscores, parentheses, hyphens, periods.`
- `Cannot end in a period`
ERROR_MESSAGE
}
}
variable "enable_telemetry" {
type = bool
default = true
description = <<DESCRIPTION
This variable controls whether or not telemetry is enabled for the module.
For more information see <https://aka.ms/avm/telemetryinfo>.
If it is set to false, then no telemetry will be collected.
DESCRIPTION
nullable = false
}
variable "lock" {
type = object({
kind = string
name = optional(string, null)
})
default = null
description = <<DESCRIPTION
Controls the Resource Lock configuration for this resource. The following properties can be specified:
- `kind` - (Required) The type of lock. Possible values are `\"CanNotDelete\"` and `\"ReadOnly\"`.
- `name` - (Optional) The name of the lock. If not specified, a name will be generated based on the `kind` value. Changing this forces the creation of a new resource.
DESCRIPTION
validation {
condition = var.lock != null ? contains(["CanNotDelete", "ReadOnly"], var.lock.kind) : true
error_message = "Lock kind must be either `\"CanNotDelete\"` or `\"ReadOnly\"`."
}
}
variable "managed_by" {
type = string
default = null
description = "(Optional) The ID of the resource or application that manages this resource group. Setting this property indicates that the resource group is managed by another service (for example a managed application or a Databricks workspace)."
validation {
condition = var.managed_by == null || can(regex("^/.+/.+", var.managed_by))
error_message = "`managed_by` must be a valid Azure resource ID starting with `/` and containing at least two `/` separated segments."
}
}
variable "retry" {
type = object({
error_message_regex = optional(list(string), ["409 Conflict"])
interval_seconds = optional(number, null)
max_interval_seconds = optional(number, null)
})
default = {}
description = <<DESCRIPTION
The retry configuration applied to the underlying `azapi_resource` resources (resource group, lock, role assignments).
- `error_message_regex` - (Optional) A list of regular expressions to match against error messages. If any of the regular expressions match, the request will be retried. Defaults to `["409"]` to retry on `409 Conflict` responses.
- `interval_seconds` - (Optional) The base number of seconds to wait between retries. Defaults to the AzAPI provider default (`10`).
- `max_interval_seconds` - (Optional) The maximum number of seconds to wait between retries. Defaults to the AzAPI provider default (`180`).
DESCRIPTION
}
variable "role_assignments" {
type = map(object({
name = optional(string, null)
role_definition_id_or_name = string
principal_id = string
description = optional(string, null)
skip_service_principal_aad_check = optional(bool, false)
condition = optional(string, null)
condition_version = optional(string, null)
delegated_managed_identity_resource_id = optional(string, null)
principal_type = optional(string, null)
}))
default = {}
description = <<DESCRIPTION
Optional. A map of role assignments to create on this resource. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.
- `name` - (Optional) The name of the role assignment. If not set, a random UUID will be generated. Must be a valid GUID. Changing this forces the creation of a new resource.
- `role_definition_id_or_name` - (Required) The ID or name of the role definition to assign to the principal.
- `principal_id` - (Required) The ID of the principal to assign the role to.
- `description` - (Optional) The description of the role assignment.
- `skip_service_principal_aad_check` - (Optional) If set to true, skips the Azure Active Directory check for the service principal in the tenant. Defaults to false.
- `condition` - (Optional) The condition which will be used to scope the role assignment.
- `condition_version` - (Optional) The version of the condition syntax. Valid values are '2.0'.
- `delegated_managed_identity_resource_id` - (Optional) The delegated Azure Resource Id which contains a Managed Identity. Changing this forces a new resource to be created. NOTE:
this field is only used in cross tenant scenario.
> Note: only set `skip_service_principal_aad_check` to true if you are assigning a role to a service principal.
Example Input:
```hcl
role_assignments = {
"role_assignment1" = {
role_definition_id_or_name = "Reader"
principal_id = "4179302c-702e-4de7-a061-beacd0a1be09"
},
"role_assignment2" = {
role_definition_id_or_name = "2a2b9908-6ea1-4ae2-8e65-a410df84e7d1" // Storage Blob Data Reader Role Guid
principal_id = "4179302c-702e-4de7-a061-beacd0a1be09"
skip_service_principal_aad_check = false
condition_version = "2.0"
condition = <<-EOT
(
(
!(ActionMatches{'Microsoft.Authorization/roleAssignments/write'})
)
OR
(
@Request[Microsoft.Authorization/roleAssignments:RoleDefinitionId]
ForAnyOfAnyValues:GuidEquals {4179302c-702e-4de7-a061-beacd0a1be09}
)
)
AND
(
(
!(ActionMatches{'Microsoft.Authorization/roleAssignments/delete'})
)
OR
(
@Resource[Microsoft.Authorization/roleAssignments:RoleDefinitionId]
ForAnyOfAnyValues:GuidEquals {dc887ae1-fe50-4307-be53-213ff08f3c0b}
)
)
EOT
}
}
```
DESCRIPTION
nullable = false
validation {
condition = alltrue(
[for role in var.role_assignments :
can(regex("^(/subscriptions/[0-9a-fA-F-]+)?/providers/Microsoft\\.Authorization/roleDefinitions/[0-9a-fA-F-]+$", role.role_definition_id_or_name))
||
can(regex("^[[:alpha:]]+?", role.role_definition_id_or_name))
]
)
error_message = <<ERROR_MESSAGE
role_definition_id_or_name must have the following format:
- Using the role definition Id : `/providers/Microsoft.Authorization/roleDefinitions/<role_guid>`
- Using the subscription-scoped role definition Id : `/subscriptions/<subscription_id>/providers/Microsoft.Authorization/roleDefinitions/<role_guid>`
- Using the role name: Reader | "Storage Blob Data Reader"
ERROR_MESSAGE
}
validation {
condition = alltrue(
[for role in var.role_assignments :
role.name == null || can(regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", coalesce(role.name, "00000000-0000-0000-0000-000000000000")))
]
)
error_message = "Each `role_assignments[*].name` must be null or a valid GUID (e.g. `00000000-0000-0000-0000-000000000000`)."
}
}
variable "tags" {
type = map(string)
default = null
description = "(Optional) Tags of the resource."
}
variable "timeouts" {
type = object({
create = optional(string, null)
delete = optional(string, null)
read = optional(string, null)
update = optional(string, null)
})
default = {}
description = <<DESCRIPTION
The timeouts applied to the underlying `azapi_resource` resources (resource group, lock, role assignments).
Each value must be a string parsable as a Go duration (for example `"30s"`, `"5m"`, `"1h30m"`). When `null`, the AzAPI provider default is used.
- `create` - (Optional) Timeout for create operations.
- `delete` - (Optional) Timeout for delete operations.
- `read` - (Optional) Timeout for read operations.
- `update` - (Optional) Timeout for update operations.
DESCRIPTION
nullable = false
}