add validation for uniqueness of username and dbname
This commit is contained in:
parent
010ac595c1
commit
4c54968793
1 changed files with 22 additions and 6 deletions
|
|
@ -61,4 +61,20 @@ variable "postgres_databases" {
|
||||||
user_name = string # username and owner for postgres db
|
user_name = string # username and owner for postgres db
|
||||||
user_roles = list(string) # List of database access levels for the user. Supported values are: login, createdb.
|
user_roles = list(string) # List of database access levels for the user. Supported values are: login, createdb.
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# Validation: each db_name must be unique
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
validation {
|
||||||
|
condition = length(distinct([for db in var.postgres_databases : db.db_name])) == length(var.postgres_databases)
|
||||||
|
error_message = "Each db_name must be unique."
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# Validation: each user_name must be unique
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
validation {
|
||||||
|
condition = length(distinct([for db in var.postgres_databases : db.user_name])) == length(var.postgres_databases)
|
||||||
|
error_message = "Each user_name must be unique."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue