Skip to content

Commit 2cb2b7c

Browse files
authoredOct 5, 2023
feat!: Remove NONE validation method and set default to null (#141)
1 parent 6e7414e commit 2cb2b7c

File tree

8 files changed

+30
-10
lines changed

8 files changed

+30
-10
lines changed
 

‎README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module "acm" {
1313
1414
domain_name = "my-domain.com"
1515
zone_id = "Z2ES7B9AZ6SHAE"
16+
17+
validation_method = "DNS"
1618
1719
subject_alternative_names = [
1820
"*.my-domain.com",
@@ -37,6 +39,8 @@ module "acm" {
3739
domain_name = "weekly.tf"
3840
zone_id = "b7d259641bf30b89887c943ffc9d2138"
3941
42+
validation_method = "DNS"
43+
4044
subject_alternative_names = [
4145
"*.weekly.tf",
4246
]
@@ -72,6 +76,8 @@ module "acm" {
7276
domain_name = "my-domain.com"
7377
zone_id = "Z266PL4W4W6MSG"
7478
79+
validation_method = "DNS"
80+
7581
wait_for_validation = true
7682
7783
tags = {
@@ -106,6 +112,8 @@ module "acm" {
106112
"app.sub.my-domain.com",
107113
]
108114
115+
validation_method = "DNS"
116+
109117
create_route53_records = false
110118
validation_record_fqdns = module.route53_records.validation_route53_record_fqdns
111119
}
@@ -121,6 +129,8 @@ module "route53_records" {
121129
create_certificate = false
122130
create_route53_records_only = true
123131
132+
validation_method = "DNS"
133+
124134
distinct_domain_names = module.acm.distinct_domain_names
125135
zone_id = "Z266PL4W4W6MSG"
126136
@@ -208,7 +218,7 @@ No modules.
208218
| <a name="input_tags"></a> [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no |
209219
| <a name="input_validate_certificate"></a> [validate\_certificate](#input\_validate\_certificate) | Whether to validate certificate by creating Route53 record | `bool` | `true` | no |
210220
| <a name="input_validation_allow_overwrite_records"></a> [validation\_allow\_overwrite\_records](#input\_validation\_allow\_overwrite\_records) | Whether to allow overwrite of Route53 records | `bool` | `true` | no |
211-
| <a name="input_validation_method"></a> [validation\_method](#input\_validation\_method) | Which method to use for validation. DNS or EMAIL are valid, NONE can be used for certificates that were imported into ACM and then into Terraform. | `string` | `"DNS"` | no |
221+
| <a name="input_validation_method"></a> [validation\_method](#input\_validation\_method) | Which method to use for validation. DNS or EMAIL are valid. This parameter must not be set for certificates that were imported into ACM and then into Terraform. | `string` | `null` | no |
212222
| <a name="input_validation_option"></a> [validation\_option](#input\_validation\_option) | The domain name that you want ACM to use to send you validation emails. This domain name is the suffix of the email addresses that you want ACM to use. | `any` | `{}` | no |
213223
| <a name="input_validation_record_fqdns"></a> [validation\_record\_fqdns](#input\_validation\_record\_fqdns) | When validation is set to DNS and the DNS validation records are set externally, provide the fqdns for the validation | `list(string)` | `[]` | no |
214224
| <a name="input_validation_timeout"></a> [validation\_timeout](#input\_validation\_timeout) | Define maximum timeout to wait for the validation to complete | `string` | `null` | no |

‎examples/complete-dns-validation-with-cloudflare/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ Note that this example may create resources which cost money. Run `terraform des
2525
|------|---------|
2626
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
2727
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.40 |
28-
| <a name="requirement_cloudflare"></a> [cloudflare](#requirement\_cloudflare) | >= 3.4 |
28+
| <a name="requirement_cloudflare"></a> [cloudflare](#requirement\_cloudflare) | >= 3.4, <=3.32 |
2929

3030
## Providers
3131

3232
| Name | Version |
3333
|------|---------|
34-
| <a name="provider_cloudflare"></a> [cloudflare](#provider\_cloudflare) | >= 3.4 |
34+
| <a name="provider_cloudflare"></a> [cloudflare](#provider\_cloudflare) | >= 3.4, <=3.32 |
3535

3636
## Modules
3737

‎examples/complete-dns-validation-with-cloudflare/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module "acm" {
2424
]
2525

2626
create_route53_records = false
27+
validation_method = "DNS"
2728
validation_record_fqdns = cloudflare_record.validation[*].hostname
2829

2930
tags = {

‎examples/complete-dns-validation-with-cloudflare/versions.tf

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ terraform {
66
source = "hashicorp/aws"
77
version = ">= 4.40"
88
}
9+
# Terraform v1.0.0 only functional with cloudflare versions less than or equal to 3.33.0
10+
# https://github.com/cloudflare/terraform-provider-cloudflare/issues/2340
11+
# Cloudflare provider version 3.33.0 introduced a regression which produced errors when
12+
# passing credentials via environment variables
13+
# https://github.com/cloudflare/terraform-provider-cloudflare/issues/2184
914
cloudflare = {
1015
source = "cloudflare/cloudflare"
11-
version = ">= 3.4"
16+
version = ">= 3.4, <=3.32"
1217
}
1318
}
1419
}

‎examples/complete-dns-validation/main.tf

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ module "acm" {
4646
"alerts.${local.domain_name}",
4747
]
4848

49+
validation_method = "DNS"
50+
4951
tags = {
5052
Name = local.domain_name
5153
}
@@ -81,6 +83,7 @@ module "acm_only" {
8183
]
8284

8385
create_route53_records = false
86+
validation_method = "DNS"
8487
validation_record_fqdns = module.route53_records_only.validation_route53_record_fqdns
8588
}
8689

@@ -93,6 +96,7 @@ module "route53_records_only" {
9396

9497
create_certificate = false
9598
create_route53_records_only = true
99+
validation_method = "DNS"
96100

97101
zone_id = local.zone_id
98102
distinct_domain_names = module.acm_only.distinct_domain_names

‎main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ resource "aws_route53_record" "validation" {
6262
}
6363

6464
resource "aws_acm_certificate_validation" "this" {
65-
count = local.create_certificate && var.validation_method != "NONE" && var.validate_certificate && var.wait_for_validation ? 1 : 0
65+
count = local.create_certificate && var.validation_method != null && var.validate_certificate && var.wait_for_validation ? 1 : 0
6666

6767
certificate_arn = aws_acm_certificate.this[0].arn
6868

‎variables.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ variable "subject_alternative_names" {
5353
}
5454

5555
variable "validation_method" {
56-
description = "Which method to use for validation. DNS or EMAIL are valid, NONE can be used for certificates that were imported into ACM and then into Terraform."
56+
description = "Which method to use for validation. DNS or EMAIL are valid. This parameter must not be set for certificates that were imported into ACM and then into Terraform."
5757
type = string
58-
default = "DNS"
58+
default = null
5959

6060
validation {
61-
condition = contains(["DNS", "EMAIL", "NONE"], var.validation_method)
62-
error_message = "Valid values are DNS, EMAIL or NONE."
61+
condition = var.validation_method == null || contains(["DNS", "EMAIL"], coalesce(var.validation_method, 0))
62+
error_message = "This variable is optional. Valid values are DNS, EMAIL, or null."
6363
}
6464
}
6565

‎wrappers/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module "wrapper" {
1212
certificate_transparency_logging_preference = try(each.value.certificate_transparency_logging_preference, var.defaults.certificate_transparency_logging_preference, true)
1313
domain_name = try(each.value.domain_name, var.defaults.domain_name, "")
1414
subject_alternative_names = try(each.value.subject_alternative_names, var.defaults.subject_alternative_names, [])
15-
validation_method = try(each.value.validation_method, var.defaults.validation_method, "DNS")
15+
validation_method = try(each.value.validation_method, var.defaults.validation_method, null)
1616
validation_option = try(each.value.validation_option, var.defaults.validation_option, {})
1717
create_route53_records = try(each.value.create_route53_records, var.defaults.create_route53_records, true)
1818
validation_record_fqdns = try(each.value.validation_record_fqdns, var.defaults.validation_record_fqdns, [])

0 commit comments

Comments
 (0)
Please sign in to comment.