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
182 stars 229 forks source link

Invalid count argument on apply #144

Closed rjcoupe closed 8 months ago

rjcoupe commented 9 months ago

Description

With a very bog-standard implementation of the module, Terraform throws the following invalid count error:

Error: Invalid count argument

on .terraform/modules/environment_ephemeral.acm/main.tf line 48, in resource "aws_route53_record" "validation":
48:   count = (local.create_certificate || local.create_route53_records_only) && var.validation_method == "DNS" && var.create_route53_records && (var.validate_certificate || local.create_route53_records_only) ? length(local.distinct_domain_names) : 0

The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the count depends on.

If your request is for a new feature, please use the Feature request template.

https://github.com/terraform-aws-modules/terraform-aws-acm/issues/10 exists, but was locked with commenters evidently still having problems.

Versions

Reproduction Code [Required]

The terraform block responsible is:

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

  domain_name = "${local.environment_root}"
  zone_id = var.hosted_zone_id

  validation_method = "DNS"

  subject_alternative_names = [
    "*.${local.environment_root}"
  ]

  wait_for_validation = true
}

Steps to reproduce the behavior:

No workspaces. Cache has been cleared as described. No steps beyond attempting to use the module as described.

Expected behavior

Basic module functionality.

Actual behavior

Error as described above on apply.

github-actions[bot] commented 8 months 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 8 months ago

This issue was automatically closed because of stale in 10 days

github-actions[bot] commented 7 months 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.