From 27664c55e1a04da164d13e7d8f8ac08cd43ffb8f Mon Sep 17 00:00:00 2001 From: nitrocode Date: Wed, 18 Aug 2021 14:15:27 -0400 Subject: [PATCH] Add zone id (#49) * zone id * Pass in zone id directly * Update test to use zone id * Update variables.tf * Auto Format * Update main.tf Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> --- README.md | 1 + docs/terraform.md | 1 + examples/complete/main.tf | 1 + main.tf | 3 ++- variables.tf | 6 ++++++ 5 files changed, 11 insertions(+), 1 deletion(-) 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