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

Invalid for_each argument #4

Open
frozeneyemr opened this issue Oct 21, 2021 · 5 comments
Open

Invalid for_each argument #4

frozeneyemr opened this issue Oct 21, 2021 · 5 comments

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                                                                                                                                                                    [12:24:13]
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?
Thnaks!

@kitsunde
Copy link
Member

Hello @frozeneyemr, I'm not actively maintaining this at the moment, but if you fix it I will review, test, merge and release it.

@frozeneyemr
Copy link
Author

Hi @kitsunde ,

will try. In my point of view the isssue comes from another module which will used : https://github.com/mediapop/terraform-aws-certificate

@kitsunde
Copy link
Member

Very possible. The last time this was touched was to upgrade from 0.12 to 0.13 which caused a lot of awkward workarounds in HCL to stop working. I would assume since then other things have shifted as well.

@frozeneyemr
Copy link
Author

already tested. The issue is in the other module. Will close here and open an issue in the other project.

@frozeneyemr
Copy link
Author

Issue is fixed in sub-module https://github.com/mediapop/terraform-aws-certificate with my last pull-request there. After merging the dependencies needs to be changed here.

@frozeneyemr frozeneyemr reopened this Oct 26, 2021
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

2 participants