diff --git a/README.md b/README.md index 2c8e8623..ee0b31f5 100644 --- a/README.md +++ b/README.md @@ -488,7 +488,7 @@ Available targets: | [timeouts\_configuration](#input\_timeouts\_configuration) | List of timeout values per action. Only valid actions are `create`, `update` and `delete` |
list(object({
create = string
update = string
delete = string
}))
| `[]` | no | | [vpc\_id](#input\_vpc\_id) | VPC ID to create the cluster in (e.g. `vpc-a22222ee`) | `string` | n/a | yes | | [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | Additional security group IDs to apply to the cluster, in addition to the provisioned default security group with ingress traffic from existing CIDR blocks and existing security groups | `list(string)` | `[]` | no | -| [zone\_id](#input\_zone\_id) | Route53 parent zone ID. If provided (not empty), the module will create sub-domain DNS records for the DB master and replicas | `string` | `""` | no | +| [zone\_id](#input\_zone\_id) | Route53 DNS Zone ID as list of string (0 or 1 items). If empty, no custom DNS name will be published.
If the list contains a single Zone ID, a custom DNS name will be pulished in that zone.
Can also be a plain string, but that use is DEPRECATED because of Terraform issues. | `any` | `[]` | no | ## Outputs diff --git a/docs/terraform.md b/docs/terraform.md index 61a64c8a..4b9eae6a 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -136,7 +136,7 @@ | [timeouts\_configuration](#input\_timeouts\_configuration) | List of timeout values per action. Only valid actions are `create`, `update` and `delete` |
list(object({
create = string
update = string
delete = string
}))
| `[]` | no | | [vpc\_id](#input\_vpc\_id) | VPC ID to create the cluster in (e.g. `vpc-a22222ee`) | `string` | n/a | yes | | [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | Additional security group IDs to apply to the cluster, in addition to the provisioned default security group with ingress traffic from existing CIDR blocks and existing security groups | `list(string)` | `[]` | no | -| [zone\_id](#input\_zone\_id) | Route53 parent zone ID. If provided (not empty), the module will create sub-domain DNS records for the DB master and replicas | `string` | `""` | no | +| [zone\_id](#input\_zone\_id) | Route53 DNS Zone ID as list of string (0 or 1 items). If empty, no custom DNS name will be published.
If the list contains a single Zone ID, a custom DNS name will be pulished in that zone.
Can also be a plain string, but that use is DEPRECATED because of Terraform issues. | `any` | `[]` | no | ## Outputs diff --git a/main.tf b/main.tf index bdc8434d..bcb8d267 100644 --- a/main.tf +++ b/main.tf @@ -346,7 +346,7 @@ module "dns_master" { enabled = local.enabled && length(var.zone_id) > 0 dns_name = local.cluster_dns_name - zone_id = var.zone_id + zone_id = try(var.zone_id[0], tostring(var.zone_id), "") records = coalescelist(aws_rds_cluster.primary.*.endpoint, aws_rds_cluster.secondary.*.endpoint, [""]) context = module.this.context @@ -358,7 +358,7 @@ module "dns_replicas" { enabled = local.enabled && length(var.zone_id) > 0 && !local.is_serverless && local.cluster_instance_count > 0 dns_name = local.reader_dns_name - zone_id = var.zone_id + zone_id = try(var.zone_id[0], tostring(var.zone_id), "") records = coalescelist(aws_rds_cluster.primary.*.reader_endpoint, aws_rds_cluster.secondary.*.reader_endpoint, [""]) context = module.this.context diff --git a/variables.tf b/variables.tf index edd228c7..0873310d 100644 --- a/variables.tf +++ b/variables.tf @@ -1,7 +1,11 @@ variable "zone_id" { - type = string - default = "" - description = "Route53 parent zone ID. If provided (not empty), the module will create sub-domain DNS records for the DB master and replicas" + type = any + default = [] + description = <<-EOT + Route53 DNS Zone ID as list of string (0 or 1 items). If empty, no custom DNS name will be published. + If the list contains a single Zone ID, a custom DNS name will be pulished in that zone. + Can also be a plain string, but that use is DEPRECATED because of Terraform issues. + EOT } variable "security_groups" {