Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create missing validation records in cases (eg, wildcard SAN) #89

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Terraform module which creates ACM certificates and validates them using Route53
```hcl
module "acm" {
source = "terraform-aws-modules/acm/aws"
version = "~> v3.0"
version = "~> 3.0"

domain_name = "my-domain.com"
zone_id = "Z2ES7B9AZ6SHAE"
Expand Down
1 change: 1 addition & 0 deletions examples/complete-dns-validation/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module "acm" {
"*.alerts.${local.domain_name}",
"new.sub.${local.domain_name}",
"*.${local.domain_name}",
"alerts.${local.domain_name}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was enough to reproduce the error.

]

wait_for_validation = true
Expand Down
9 changes: 7 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ locals {
[for s in concat([var.domain_name], var.subject_alternative_names) : replace(s, "*.", "")]
)

# Copy domain_validation_options for the distinct domain names
validation_domains = var.create_certificate ? [for k, v in aws_acm_certificate.this[0].domain_validation_options : tomap(v) if contains(local.distinct_domain_names, replace(v.domain_name, "*.", ""))] : []
# Get the list of distinct domain_validation_options, with wildcard
# domain names replaced by the domain name
validation_domains = var.create_certificate ? distinct(
[for k, v in aws_acm_certificate.this[0].domain_validation_options : merge(
tomap(v), { domain_name = replace(v.domain_name, "*.", "") }
)]
) : []
}

resource "aws_acm_certificate" "this" {
Expand Down