forked from tasador/terraform-azuread-service-principal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.tf
59 lines (50 loc) · 1.68 KB
/
variables.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
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
variable "name" {
type = string
description = "The name of the service principal."
}
variable "password" {
type = string
default = ""
description = "A password for the service principal."
}
variable "end_date" {
type = string
default = "1Y"
description = "The relative duration or RFC3339 date after which the password expire."
}
variable "role" {
type = string
default = ""
description = "The name of a role for the service principal."
}
variable "scopes" {
type = list(string)
default = []
description = "List of scopes the role assignment applies to."
}
locals {
scopes = length(var.scopes) > 0 ? var.scopes : [data.azurerm_subscription.main.id]
date = regexall("^(?:(\\d{4})-(\\d{2})-(\\d{2}))[Tt]?(?:(\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.(\\d+))?)?([Zz]|[\\+|\\-]\\d{2}:\\d{2})?$", var.end_date)
duration = regexall("^(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)W)?(?:(\\d+)D)?(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?$", var.end_date)
end_date_relative = length(local.duration) > 0 ? format(
"%dh",
(
(coalesce(local.duration[0][0], 0) * 24 * 365) +
(coalesce(local.duration[0][1], 0) * 24 * 30) +
(coalesce(local.duration[0][2], 0) * 24 * 7) +
(coalesce(local.duration[0][3], 0) * 24) +
coalesce(local.duration[0][4], 0)
)
) : null
end_date = length(local.date) > 0 ? format(
"%02d-%02d-%02dT%02d:%02d:%02d.%02d%s",
local.date[0][0],
local.date[0][1],
local.date[0][2],
coalesce(local.date[0][3], "23"),
coalesce(local.date[0][4], "59"),
coalesce(local.date[0][5], "00"),
coalesce(local.date[0][6], "00"),
coalesce(local.date[0][7], "Z")
) : null
}