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

Getting a cycle error #121

Closed ir-vsem closed 2 years ago

ir-vsem commented 2 years ago

Description

I'm getting a cycle error.

my code:

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

  for_each    = toset(var.service_name)
  domain_name = "${local.resource_prefix}-${each.key}.${var.domain_name}"

  create_route53_records  = false
  validation_record_fqdns = module.acm_route53_records.validation_route53_record_fqdns

}

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

  providers = {aws = aws.main}

  for_each    = toset(var.service_name)

  create_certificate          = false
  create_route53_records_only = true

  zone_id               = data.aws_route53_zone.selected.id
  distinct_domain_names = module.acm[each.key].distinct_domain_names

  acm_certificate_domain_validation_options = module.acm[each.key].acm_certificate_domain_validation_options

}

error:

Error: Cycle: module.acm_route53_records.var.distinct_domain_names (expand), module.acm_route53_records.local.distinct_domain_names (expand), module.acm_route53_records.var.acm_certificate_domain_validation_options (expand), module.acm_route53_records.local.validation_domains (expand), module.acm_route53_records.aws_route53_record.validation, module.acm_route53_records.output.validation_route53_record_fqdns (expand), module.acm.var.validation_record_fqdns (expand), module.acm.aws_acm_certificate_validation.this, module.acm.output.acm_certificate_arn (expand), module.acm (close)

if I only run with just the acm only block it works fine.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

antonbabenko commented 2 years ago

I don't see an immediate issue other than the missing index ([each.key]) here:

validation_record_fqdns = module.acm_route53_records[each.key].validation_route53_record_fqdns
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.