Skip to content

Commit

Permalink
chore: validate format of input domain variables
Browse files Browse the repository at this point in the history
  • Loading branch information
josephpage committed Sep 15, 2023
1 parent bdfc591 commit f4f1765
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,27 @@ variable "domain" {
description = "Main domain name of the application, known as \"canonical domain\" in Scalingo's dashboard. Note that SSL configuration must be completed through the dashboard."
type = string
default = null
nullable = true

validation {
condition = var.domain == null || can(length(regex("^([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$", var.domain)) > 0)
error_message = "The domain name must be a valid domain name."
}
}

variable "domain_aliases" {
description = "List of others domain names for the application"
type = list(string)
default = []
nullable = false

validation {
condition = length([
for domain in var.domain_aliases :
domain if can(length(regex("^([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$", domain)) == 0)
]) == 0
error_message = "The list of domain names must contain only valid domain names."
}
}

variable "log_drains" {
Expand Down

0 comments on commit f4f1765

Please sign in to comment.