35 lines
1.2 KiB
HCL
35 lines
1.2 KiB
HCL
// Postgres Instance
|
|
resource "stackit_postgresflex_instance" "this" {
|
|
project_id = var.stackit_project_id
|
|
name = var.postgres_instance_name
|
|
acl = var.postgres_instance_acl
|
|
backup_schedule = var.postgres_instance_backup_schedule
|
|
flavor = var.postgres_instance_flavor
|
|
replicas = var.postgres_instance_replicas
|
|
storage = var.postgres_instance_storage
|
|
version = var.postgres_instance_version
|
|
}
|
|
|
|
// Postgres User
|
|
resource "stackit_postgresflex_user" "this" {
|
|
for_each = {
|
|
for db in var.postgres_databases : db.user_name => db
|
|
}
|
|
depends_on = [ stackit_postgresflex_instance.this ]
|
|
project_id = var.stackit_project_id
|
|
instance_id = stackit_postgresflex_instance.this.instance_id
|
|
username = each.value.user_name
|
|
roles = each.value.user_roles
|
|
}
|
|
|
|
// Postgres Database
|
|
resource "stackit_postgresflex_database" "this" {
|
|
for_each = {
|
|
for db in var.postgres_databases : db.db_name => db
|
|
}
|
|
depends_on = [stackit_postgresflex_user.this]
|
|
project_id = var.stackit_project_id
|
|
instance_id = stackit_postgresflex_instance.this.instance_id
|
|
name = each.value.db_name
|
|
owner = each.value.user_name
|
|
}
|