terraform-aws-modules / terraform-aws-acm

Terraform module to create AWS ACM resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/acm/aws
Apache License 2.0
184 stars 230 forks source link

local.validation_domains is empty tuple #56

Closed gte250p closed 4 years ago

gte250p commented 4 years ago

Looks like the tomap(v) if which resides in the validation_domains local definition has some issue. In my case, I get the certificate created correctly, and it is in "Pending validation" state. The output for terraform state show aws_acm_certificate.this[0] looks something like this:

# aws_acm_certificate.this[0]:
resource "aws_acm_certificate" "this" {
    arn                       = "arn:aws:acm:us-east-1:...:certificate/..."
    domain_name               = "...dns..."
    domain_validation_options = [
        {
            domain_name           = "..dns..."
            resource_record_name  = "_2f359f5034...."
            resource_record_type  = "CNAME"
            resource_record_value = "_4ee8dd8d.....acm-validations.aws."
        },
        {
            domain_name           = "*...."
            resource_record_name  = "_2f35..."
            resource_record_type  = "CNAME"
            resource_record_value = "_4ee8dd...acm-validations.aws."
        },
    ]
    id                        = "arn:aws:acm:us-east-1:...:certificate/..."
    status                    = "PENDING_VALIDATION"
    subject_alternative_names = [
        "*....",
    ]
    tags                      = {
    ....
    }
    validation_emails         = []
    validation_method         = "DNS"
    options {
        certificate_transparency_logging_preference = "ENABLED"
    }
}

Note that for my project I can't plan, destroy, apply - nothing because it says that error:

  on main.tf line 31, in resource "aws_route53_record" "validation":
  31:   name    = element(local.validation_domains, count.index)["resource_record_name"]
    |----------------
    | count.index is 1
    | local.validation_domains is empty tuple

The solution I've found that works is to remove the if contains(local.distinct_domain_names, replace(v.domain_name, "*.", "")) from main.tf.

gte250p commented 4 years ago

Ok, I figured out what was going on. To help others, my Domain name ended in the period, so my.domain.com.

Running trim on it fixed this issue: trim(domain_name, ".")

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.