# Variables ================================================================== # Organization Root ID ------------------------------------------------------- # # Notes: # - Found in AWS Organizations console under the Root entry # - Format is "r-" followed by lowercase alphanumeric characters # - Example: r-wxyz # variable "root_id" { description = "Organization root ID under which top-level OUs are created (e.g. r-xxxx)" type = string validation { condition = can(regex("^r-[a-z0-9]+$", var.root_id)) error_message = "root_id must start with an 'r-' followed by lowercase alphanumeric characters." } } # OU Structure --------------------------------------------------------------- # # Notes: # - Supports nesting up to 3 levels deep (e.g. Workloads > ACME > Prod) # - parent_key must be 'root' or reference another key in this map # - The key 'root' is reserved and cannot be used as an OU key # - Per-OU tags are merged with module-level tags; per-OU tags win on conflicts # # Example: # organizational_units = { # workloads = { # name = "Workloads" # parent_key = "root" # } # workloads_prod = { # name = "Prod" # parent_key = "workloads" # tags = { env = "prod" } # } # } # variable "organizational_units" { description = <<-EOT Map of OU definitions. Each key is a logical name used internally. parent_key references another key in this map (or 'root' for top-level OUs). EOT type = map(object({ name = string parent_key = string tags = optional(map(string), {}) })) validation { condition = !contains(keys(var.organizational_units), "root") error_message = "The key 'root' is reserved and cannot be used as an OU key." } validation { condition = alltrue([ for k, v in var.organizational_units : v.parent_key == "root" || contains(keys(var.organizational_units), v.parent_key) ]) error_message = "All parent_key values must be 'root' or reference an existing key in organizational_units." } }