generated from getindata/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
variables.tf
202 lines (182 loc) · 6.89 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
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
200
201
202
variable "name" {
description = "Name of the resource"
type = string
}
variable "comment" {
description = "Role description"
type = string
default = null
}
variable "role_ownership_grant" {
description = "The name of the role to grant ownership"
type = string
default = null
}
variable "granted_roles" {
description = "Roles granted to this role"
type = list(string)
default = []
}
variable "granted_database_roles" {
description = "Database Roles granted to this role"
type = list(string)
default = []
}
variable "granted_to_roles" {
description = "Roles which this role is granted to"
type = list(string)
default = []
}
variable "granted_to_users" {
description = "Users which this role is granted to"
type = list(string)
default = []
}
variable "account_grants" {
description = "Grants on a account level"
type = list(object({
all_privileges = optional(bool)
with_grant_option = optional(bool, false)
privileges = optional(list(string), null)
}))
default = []
validation {
condition = alltrue([for grant in var.account_grants : (grant.privileges != null) != (grant.all_privileges == true)])
error_message = "Variable `account_grants` fails validation - only one of `privileges` or `all_privileges` can be set."
}
}
variable "account_objects_grants" {
description = <<EOT
Grants on account object level.
Account objects list: USER | RESOURCE MONITOR | WAREHOUSE | COMPUTE POOL | DATABASE | INTEGRATION | FAILOVER GROUP | REPLICATION GROUP | EXTERNAL VOLUME
Object type is used as a key in the map.
Exmpale usage:
```
account_object_grants = {
"WAREHOUSE" = [
{
all_privileges = true
with_grant_option = true
object_name = "TEST_USER"
}
]
"DATABASE" = [
{
privileges = ["CREATE SCHEMA", "CREATE DATABASE ROLE"]
object_name = "TEST_DATABASE"
},
{
privileges = ["CREATE SCHEMA"]
object_name = "OTHER_DATABASE"
}
]
}
```
Note: You can find a list of all object types [here](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_privileges_to_account_role#nested-schema-for-on_account_object)
EOT
type = map(list(object({
all_privileges = optional(bool)
with_grant_option = optional(bool, false)
privileges = optional(list(string), null)
object_name = string
})))
default = {}
validation {
condition = alltrue([for object_type, grants in var.account_objects_grants : alltrue([for grant in grants : (grant.privileges != null) != (grant.all_privileges != null)])])
error_message = "Variable `account_objects_grants` fails validation - only one of `privileges` or `all_privileges` can be set."
}
}
variable "schema_grants" {
description = "Grants on a schema level"
type = list(object({
all_privileges = optional(bool)
with_grant_option = optional(bool, false)
privileges = optional(list(string), null)
all_schemas_in_database = optional(bool, false)
future_schemas_in_database = optional(bool, false)
database_name = string
schema_name = optional(string, null)
}))
default = []
validation {
condition = alltrue([for grant in var.schema_grants : (grant.privileges != null) != (grant.all_privileges == true)])
error_message = "Variable `schema_grants` fails validation - only one of `privileges` or `all_privileges` can be set."
}
}
variable "schema_objects_grants" {
description = <<EOF
Grants on a schema object level
Example usage:
```
schema_objects_grants = {
"TABLE" = [
{
privileges = ["SELECT"]
object_name = snowflake_table.table_1.name
schema_name = snowflake_schema.this.name
},
{
all_privileges = true
object_name = snowflake_table.table_2.name
schema_name = snowflake_schema.this.name
}
]
"ALERT" = [
{
all_privileges = true
on_future = true
on_all = true
}
]
}
```
Note: If you don't provide a schema_name, the grants will be created for all objects of that type in the database.
You can find a list of all object types [here](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_privileges_to_database_role#object_type)
EOF
type = map(list(object({
all_privileges = optional(bool)
with_grant_option = optional(bool)
privileges = optional(list(string))
object_name = optional(string)
on_all = optional(bool, false)
schema_name = optional(string)
database_name = string
on_future = optional(bool, false)
})))
default = {}
validation {
condition = alltrue([for object_type, grants in var.schema_objects_grants : alltrue([for grant in grants : (grant.privileges != null) != (grant.all_privileges != null)])])
error_message = "Variable `schema_objects_grants` fails validation - only one of `privileges` or `all_privileges` can be set."
}
validation {
condition = alltrue([for object_type, grants in var.schema_objects_grants : alltrue([for grant in grants :
!(grant.object_name != null && (grant.on_all == true || grant.on_future == true))
])])
error_message = "Variable `schema_objects_grants` fails validation - `object_name` cannot be set with `on_all` or `on_future`."
}
}
variable "name_scheme" {
description = <<EOT
Naming scheme configuration for the resource. This configuration is used to generate names using context provider:
- `properties` - list of properties to use when creating the name - is superseded by `var.context_templates`
- `delimiter` - delimited used to create the name from `properties` - is superseded by `var.context_templates`
- `context_template_name` - name of the context template used to create the name
- `replace_chars_regex` - regex to use for replacing characters in property-values created by the provider - any characters that match the regex will be removed from the name
- `extra_values` - map of extra label-value pairs, used to create a name
- `uppercase` - convert name to uppercase
EOT
type = object({
properties = optional(list(string), ["environment", "name"])
delimiter = optional(string, "_")
context_template_name = optional(string, "snowflake-role")
replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")
extra_values = optional(map(string))
uppercase = optional(bool, true)
})
default = {}
}
variable "context_templates" {
description = "Map of context templates used for naming conventions - this variable supersedes `naming_scheme.properties` and `naming_scheme.delimiter` configuration"
type = map(string)
default = {}
}