dafine list for user and db in postgbres module

This commit is contained in:
Michael Messmer 2025-09-08 09:30:45 +02:00
parent 3318babf7c
commit 9539b43f7d
2 changed files with 20 additions and 26 deletions

View file

@ -12,18 +12,24 @@ resource "stackit_postgresflex_instance" "this" {
// 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 = var.postgres_db_user_name
roles = var.postgres_db_user_roles
username = each.value.user_name
roles = each.value.user_roles
}
// Postgres Database
resource "stackit_postgresflex_database" "this" {
depends_on = [ stackit_postgresflex_user.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 = var.postgres_db_name
owner = var.postgres_db_user_name
}
name = each.value.db_name
owner = each.value.user_name
}