-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Using for_each with aws_acm_certificate.domain_validation_options #10997
Comments
should be sufficient to use |
Hi folks 👋 As @so0k mentions above, it should be sufficient to wrap the reference to # Terraform CLI 0.12+ and Terraform AWS Provider 2.X compatible
resource "aws_route53_record" "example" {
for_each = toset(aws_acm_certificate.example.domain_validation_options)
name = each.value.resource_record_name
records = [each.value.resource_record_value]
ttl = 60
type = each.value.resource_record_type
zone_id = aws_route53_zone.example.zone_id
} Please note that I'm explicitly mentioning version 2.X of the provider here since we plan to fix the ordering issues of Please follow the two issues mentioned above for further tracking of this work and documentation. |
No solution for this if I am on Terraform 0.11.x? @bflad |
@bflad - Your solution here gives me this error output: Error: Invalid for_each set argument
on modules/acm/main.tf line 13, in resource "aws_route53_record" "route53_record_certificate_validation_default":
13: for_each = toset(aws_acm_certificate.acm_certificate_default.domain_validation_options)
The given "for_each" argument value is unsuitable: "for_each" supports maps
and sets of strings, but you have provided a set containing type object. I've tried using tomap() as well and get a similar error. Any ideas regarding this would be greatly apprecaited. |
Found a solution: for_each = { for option in aws_acm_certificate.acm_certificate_default.domain_validation_options: option.resource_record_name => option } |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Description
The following piece of code:
Produces the following error:
This seems like a waste of potential, seeing as
for_each
is the perfect tool to actually implement validation in terraform "correctly".Right now you have to do something ugly with the config like this:
And if you want alternative domain validation you have to copy that. The docs even suggest so:
https://www.terraform.io/docs/providers/aws/r/acm_certificate_validation.html#alternative-domains-dns-validation-with-route-53
New or Affected Resource(s)
The text was updated successfully, but these errors were encountered: