-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
57 lines (49 loc) · 1.54 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
locals {
access_map_ro = {
table_rights = ["SELECT"]
sequence_rights = ["USAGE"]
schema_rights = ["USAGE"]
database_rights = ["CONNECT"]
}
access_map_rw = {
table_rights = ["SELECT", "UPDATE", "INSERT", "DELETE", "TRIGGER", "REFERENCES", "TRUNCATE"]
sequence_rights = ["SELECT", "UPDATE"]
schema_rights = ["USAGE"],
database_rights = ["CONNECT"],
}
}
module "database" {
source = "./modules/database"
database_name = var.database
owner_username = var.owner_username
}
module "access_ro" {
source = "./modules/access"
database_name = var.database
database_owner = module.database.username
role_name = var.role_ro_name != null ? var.role_ro_name : "${var.database}_ro"
create_role = var.create_role_ro
allow_login = false
access_map = local.access_map_ro
depends_on = [module.database]
}
module "access_rw" {
source = "./modules/access"
database_name = var.database
database_owner = module.database.username
role_name = var.role_rw_name != null ? var.role_rw_name : "${var.database}_rw"
create_role = var.create_role_rw
allow_login = false
access_map = local.access_map_rw
depends_on = [module.database]
}
module "access_app" {
source = "./modules/access"
database_name = var.database
database_owner = module.database.username
role_name = var.app_username != null ? var.app_username : "${var.database}_app"
create_role = true
allow_login = true
access_map = local.access_map_rw
depends_on = [module.database]
}