A common mistake I make is confusing name with domain, and the subsequent name constraints around them:
name = name of the managed zone, must be lowercases chars and dashes
domain = DNS domain name, must end in .
Having some validations around these to detect them at the plan state would be great, or, better, yet, being able to essentially auto-correct these via string manipulation.
Terraform Resources
google_dns_managed_zone
Detailed design
variable "name" {
description = "Zone name, must be unique within the project."
type = string
default = null
}
# Auto-generate name based on domain:
name = lower(coalesce(var.name, trimsuffix(replace(var.domain, ".", "-"), "-")))
# Add a '.' to domain if required:
dns_name = endswith(var.domain, ".") ? var.domain : "${var.domain}."
TL;DR
A common mistake I make is confusing
name
withdomain
, and the subsequent name constraints around them:name = name of the managed zone, must be lowercases chars and dashes domain = DNS domain name, must end in .
Having some validations around these to detect them at the plan state would be great, or, better, yet, being able to essentially auto-correct these via string manipulation.
Terraform Resources
Detailed design
Additional information
https://github.com/aws2gcp/gcp-network-terraform/blob/main/dns/dns_zones.tf