diff --git a/postgres/main.tf b/postgres/main.tf index 0507717..75f628d 100644 --- a/postgres/main.tf +++ b/postgres/main.tf @@ -18,7 +18,7 @@ resource "stackit_postgresflex_user" "user" { count = local.user_count project_id = var.project_id - instance_id = stackit_postgresflex_instance.this.instance_id + instance_id = var.instance_id != "" ? var.instance_id : stackit_postgresflex_instance.this.instance_id username = var.users[count.index].username roles = var.users[count.index].roles } diff --git a/postgres/variables.tf b/postgres/variables.tf index dbe1920..061dd3f 100644 --- a/postgres/variables.tf +++ b/postgres/variables.tf @@ -4,6 +4,21 @@ variable "project_id" { variable "name" { type = string + + validation { + condition = length(regexall("^[a-z]([-a-z0-9]*[a-z0-9])?$", var.name)) > 0 + error_message = < 0 + ]) + error_message = <