-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
29 lines (26 loc) · 879 Bytes
/
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
resource "postgresql_database" "main" {
name = var.name
encoding = var.encoding
lc_collate = var.lc_collate
lc_ctype = var.lc_ctype
connection_limit = var.connection_limit
allow_connections = var.allow_connections
owner = var.make_owner ? postgresql_role.role.name : null
}
resource "random_password" "password" {
length = var.password.length
special = var.password.special
min_numeric = var.password.min_numeric
min_lower = var.password.min_lower
}
resource "postgresql_role" "role" {
name = var.role == null ? var.name : var.role
login = true
password = random_password.password.result
}
resource "postgresql_grant" "database" {
database = postgresql_database.main.name
role = postgresql_role.role.name
object_type = "database"
privileges = var.privileges
}