generated from getindata/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
100 lines (78 loc) · 3.2 KB
/
main.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
data "context_label" "this" {
delimiter = local.context_template == null ? var.name_scheme.delimiter : null
properties = local.context_template == null ? var.name_scheme.properties : null
template = local.context_template
replace_chars_regex = var.name_scheme.replace_chars_regex
values = merge(
var.name_scheme.extra_values,
{ name = var.name }
)
}
resource "snowflake_warehouse" "this" {
name = var.name_scheme.uppercase ? upper(data.context_label.this.rendered) : data.context_label.this.rendered
comment = var.comment
warehouse_size = var.warehouse_size
warehouse_type = var.warehouse_type
auto_resume = var.auto_resume
auto_suspend = var.auto_suspend
initially_suspended = var.initially_suspended
min_cluster_count = var.min_cluster_count
max_cluster_count = var.max_cluster_count
scaling_policy = var.scaling_policy
max_concurrency_level = var.max_concurrency_level
enable_query_acceleration = var.enable_query_acceleration
query_acceleration_max_scale_factor = var.query_acceleration_max_scale_factor
statement_queued_timeout_in_seconds = var.statement_queued_timeout_in_seconds
statement_timeout_in_seconds = var.statement_timeout_in_seconds
resource_monitor = var.resource_monitor
}
moved {
from = snowflake_warehouse.this[0]
to = snowflake_warehouse.this
}
module "snowflake_default_role" {
for_each = local.default_roles #{ for role_name, role in local.default_roles : role_name => role if var.create_default_roles }
source = "getindata/role/snowflake"
version = "3.1.0"
context_templates = var.context_templates
name = each.key
name_scheme = merge(
local.default_role_naming_scheme,
lookup(each.value, "name_scheme", {})
)
role_ownership_grant = lookup(each.value, "role_ownership_grant", "SYSADMIN")
granted_to_users = lookup(each.value, "granted_to_users", [])
granted_to_roles = lookup(each.value, "granted_to_roles", [])
granted_roles = lookup(each.value, "granted_roles", [])
account_objects_grants = {
WAREHOUSE = [{
all_privileges = each.value.warehouse_grants.all_privileges
privileges = each.value.warehouse_grants.privileges
with_grant_option = each.value.warehouse_grants.with_grant_option
object_name = snowflake_warehouse.this.name
}]
}
}
module "snowflake_custom_role" {
for_each = local.custom_roles
source = "getindata/role/snowflake"
version = "3.1.0"
context_templates = var.context_templates
name = each.key
name_scheme = merge(
local.default_role_naming_scheme,
lookup(each.value, "name_scheme", {})
)
role_ownership_grant = lookup(each.value, "role_ownership_grant", "SYSADMIN")
granted_to_users = lookup(each.value, "granted_to_users", [])
granted_to_roles = lookup(each.value, "granted_to_roles", [])
granted_roles = lookup(each.value, "granted_roles", [])
account_objects_grants = {
WAREHOUSE = [{
all_privileges = each.value.warehouse_grants.all_privileges
privileges = each.value.warehouse_grants.privileges
with_grant_option = each.value.warehouse_grants.with_grant_option
object_name = snowflake_warehouse.this.name
}]
}
}