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

example not working, error required output is empty list of dynamic #129

Closed g18z0n closed 1 year ago

g18z0n commented 1 year ago

Description

When trying the example 'complete-dns-validation-with-cloudflare', the output 'module.acm.validation_domains' used on the cloudflare_record resource throws an error that the output is empty list of dynamic so it cannot iterate over it.

Versions

Reproduction Code [Required]

module "acm" {
  source = "terraform-aws-modules/acm/aws"
  version = "~> 4.0"

  domain_name = "example-domain.com"
  zone_id = data.cloudflare_zone.this.id

  subject_alternative_names = [
    "*.example-domain.com"
  ]

  create_route53_records  = false
  validation_record_fqdns = cloudflare_record.validation[*].hostname
}

resource "cloudflare_record" "validation" {
  count = length(module.acm.distinct_domain_names)

  zone_id = data.cloudflare_zone.this.id
  name    = element(module.acm.validation_domains, count.index)["resource_record_name"]
  type    = element(module.acm.validation_domains, count.index)["resource_record_type"]
  value   = trimsuffix(element(module.acm.validation_domains, count.index)["resource_record_value"], ".")
  ttl     = 60
  proxied = false

  allow_overwrite = true
}

Steps to reproduce the behavior:

terraform plan

Expected behavior

The plan should work, listing the cloudflare record(s) to be created.

Actual behavior

The plan throws an error that the 'module.acm.validation_domains' output is empty list of dynamic.

Terminal Output Screenshot(s)

β”‚ Error: Error in function call
β”‚
β”‚   on main.tf line 34, in resource "cloudflare_record" "validation":
β”‚  182:   value   = trimsuffix(element(module.acm.validation_domains, count.index)["resource_record_value"], ".")
β”‚     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     β”‚ while calling element(list, index)
β”‚     β”‚ count.index is 0
β”‚     β”‚ module.acm.validation_domains is empty list of dynamic
β”‚
β”‚ Call to function "element" failed: cannot use element function with an empty list.
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 1 year ago

This issue was automatically closed because of stale in 10 days

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.