diff --git a/README.md b/README.md
index cd7610e..c583dbd 100644
--- a/README.md
+++ b/README.md
@@ -194,6 +194,7 @@ Available targets:
| [ttl](#input\_ttl) | The TTL of the record to add to the DNS zone to complete certificate validation | `string` | `"300"` | no |
| [validation\_method](#input\_validation\_method) | Method to use for validation, DNS or EMAIL | `string` | `"DNS"` | no |
| [wait\_for\_certificate\_issued](#input\_wait\_for\_certificate\_issued) | Whether to wait for the certificate to be issued by ACM (the certificate status changed from `Pending Validation` to `Issued`) | `bool` | `false` | no |
+| [zone\_id](#input\_zone\_id) | The zone id of the Route53 Hosted Zone which can be used instead of `var.zone_name`. | `string` | `null` | no |
| [zone\_name](#input\_zone\_name) | The name of the desired Route53 Hosted Zone | `string` | `""` | no |
## Outputs
diff --git a/docs/terraform.md b/docs/terraform.md
index 70434e0..2b0a6f4 100644
--- a/docs/terraform.md
+++ b/docs/terraform.md
@@ -53,6 +53,7 @@
| [ttl](#input\_ttl) | The TTL of the record to add to the DNS zone to complete certificate validation | `string` | `"300"` | no |
| [validation\_method](#input\_validation\_method) | Method to use for validation, DNS or EMAIL | `string` | `"DNS"` | no |
| [wait\_for\_certificate\_issued](#input\_wait\_for\_certificate\_issued) | Whether to wait for the certificate to be issued by ACM (the certificate status changed from `Pending Validation` to `Issued`) | `bool` | `false` | no |
+| [zone\_id](#input\_zone\_id) | The zone id of the Route53 Hosted Zone which can be used instead of `var.zone_name`. | `string` | `null` | no |
| [zone\_name](#input\_zone\_name) | The name of the desired Route53 Hosted Zone | `string` | `""` | no |
## Outputs
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index e1f3177..632ada6 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -14,6 +14,7 @@ module "zone" {
module "acm_request_certificate" {
source = "../../"
domain_name = module.zone.zone_name
+ zone_id = module.zone.zone_id
validation_method = var.validation_method
ttl = var.ttl
subject_alternative_names = ["*.${module.zone.zone_name}"]
diff --git a/main.tf b/main.tf
index e0cbde2..c391985 100644
--- a/main.tf
+++ b/main.tf
@@ -21,7 +21,8 @@ locals {
data "aws_route53_zone" "default" {
count = local.process_domain_validation_options ? 1 : 0
- name = local.zone_name
+ zone_id = var.zone_id
+ name = try(length(var.zone_id), 0) == 0 ? local.zone_name : null
private_zone = false
}
diff --git a/variables.tf b/variables.tf
index 96dd8f4..2fa492e 100644
--- a/variables.tf
+++ b/variables.tf
@@ -39,6 +39,12 @@ variable "zone_name" {
description = "The name of the desired Route53 Hosted Zone"
}
+variable "zone_id" {
+ type = string
+ default = null
+ description = "The zone id of the Route53 Hosted Zone which can be used instead of `var.zone_name`."
+}
+
variable "certificate_transparency_logging_preference" {
type = bool
default = true