commit
64be99308b
53 files changed
+1983
No files matched your search
@@ -0,0 +1,42 @@
|
||||
resource "random_password" "this" {
|
||||
for_each = local.databases
|
||||
length = 32
|
||||
special = false
|
||||
}
|
||||
|
||||
resource "postgresql_role" "this" {
|
||||
for_each = local.databases
|
||||
name = each.value.username
|
||||
login = true
|
||||
password = random_password.this[each.key].result
|
||||
}
|
||||
|
||||
resource "postgresql_database" "this" {
|
||||
for_each = local.databases
|
||||
name = each.key
|
||||
owner = postgresql_role.this[each.key].name
|
||||
}
|
||||
|
||||
resource "postgresql_extension" "vector" {
|
||||
for_each = { for key, value in local.databases : key => value if value.pgvector }
|
||||
name = "vector"
|
||||
database = postgresql_database.this[each.key].name
|
||||
}
|
||||
|
||||
resource "postgresql_grant" "public" {
|
||||
for_each = postgresql_database.this
|
||||
database = each.value.name
|
||||
role = "public"
|
||||
object_type = "database"
|
||||
privileges = []
|
||||
}
|
||||
|
||||
resource "postgresql_grant" "owner" {
|
||||
for_each = postgresql_database.this
|
||||
database = each.value.name
|
||||
role = postgresql_role.this[each.key].name
|
||||
object_type = "database"
|
||||
privileges = ["CONNECT", "CREATE", "TEMPORARY"]
|
||||
|
||||
depends_on = [postgresql_grant.public]
|
||||
}
|
||||
Reference in new issue
Block a user