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

Error: Invalid for_each argument when using more than one needed DNs #2

Open
frozeneyemr opened this issue Oct 21, 2021 · 1 comment

Comments

@frozeneyemr
Copy link

Hi,

I'm not able to use more than one source aliases for the redirect like shown in the default example.
"mediapopinc.com." = ["mediapopinc.com", "www.mediapopinc.com"]
This is failing with following error:

Error: Invalid for_each argument
│ 
│   on .terraform/modules/redirect0.certificate/main.tf line 26, in resource "aws_route53_record" "record":
│   26:   for_each = {
│   27:     // Asking for aws_acm_certificate.cert.0 will raise an exception when no certificate is being setup.
│   28:     for dvo in flatten(aws_acm_certificate.cert.*.domain_validation_options) : dvo.domain_name => {
│   29:       name  = dvo.resource_record_name
│   30:       value = dvo.resource_record_value
│   31:       type  = dvo.resource_record_type
│   32:       zone_id = data.aws_route53_zone.zone[local.host_to_zone[dvo.domain_name]].zone_id
│   33:     }
│   34:   }
│     ├────────────────
│     │ aws_acm_certificate.cert is tuple with 1 element
│     │ data.aws_route53_zone.zone is object with 1 attribute "awstest.adesso-test.de."
│     │ local.host_to_zone is object with 2 attributes
│ 
│ The "for_each" 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 for_each depends on.

Version Info:

$ terraform --version                                                                                                                                                                    Terraform v1.0.9
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.63.0

It's working only with one entry behind the domain, f.eg. "mediapopinc.com." = ["mediapopinc.com"]

I've also tried to apply with target option for different ressources but with no success. Any ideas?
Thanks!

@frozeneyemr
Copy link
Author

#3 fixes this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant