-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.tf
136 lines (121 loc) · 3.79 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
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
variable "users" {
description = <<EOT
A list of objects representing a composite vault user entity, defining a role
and login.
The `alias` property is used to have a proper handle for each distinct entity.
It must be unique.
The `policies` property contains a map that defines how a specific vault policy
gets applied to the session.
The `password` property is the initial login password of a user. The password
can be self rotated via the policy `change-pw`. Changes in this property do not
cause a state change for terraforms livecycle.
The `metadata` property hold arbitrary map of data, that we can use for auditing
purposes e.g.
Validations are done for password format and user alias uniqueness.
Concerned resources:
- [vault_generic_endpoint](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/generic_endpoint)
- [vault_identity_entity](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/identity_entity)
- [vault_identity_entity_policies](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/identity_entity_policies)
- [vault_identity_entity_alias](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/identity_entity_alias)
- [vault_identity_group](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/identity_group)
EOT
type = list(object({
alias = string
identity = object({
external_policies = bool
exclusive = bool
})
policies = object({
from_auth = list(string)
from_entity = list(string)
from_groups = list(string)
})
metadata = map(string)
}))
//validation {
// condition = contains(
// [for u in var.users : length(u.password) > 16], true
// )
// error_message = "The initial password must be longer than 16."
//}
//validation {
// condition = contains(
// [for u in var.users :
// can(regex("^.*", u.password))],
// true)
// error_message = "Initial password for user must be special."
//}
validation {
condition = length(compact([for u in var.users : u.alias])) == length(var.users)
error_message = "All user aliases must be unique. Tf wont show this validation."
}
default = [
{
alias = "test-user"
identity = {
external_policies = true
exclusive = false
}
policies = {
from_auth = ["change-pw"]
from_entity = ["personal"]
from_groups = ["users", "operators"]
}
otc = {
groups = []
roles = []
}
metadata = {
FullName = "Max Musterman"
Role = "operator"
Email = "[email protected]"
}
},
]
}
variable "groups" {
description = <<EOT
A list of objects representing a vault user group, defining a role
and permissions.
Concerned resources:
- [vault_identity_group](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/identity_group)
EOT
type = list(object({
type = string
policies = list(string)
name = string
metadata = map(string)
}))
validation {
condition = length(compact([for g in var.groups : g.name])) == length(var.groups)
error_message = "All group names must be unique. Tf wont show this validation."
}
default = [
{
name = "operators"
type = "internal"
policies = ["operator"]
metadata = {
version = "1"
name = "operators"
}
},
{
name = "users"
type = "internal"
policies = ["user"]
metadata = {
version = "1"
name = "users"
}
}
]
}
variable "kv_secret_backend" {
type = object({
path = string
type = string
description = string
# options = set(object({}))
})
}