-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
Fix for Error: Invalid for_each argument
#13
Fix for Error: Invalid for_each argument
#13
Conversation
…nment name. However the permission_set_arn can not be determined until after the apply of the permission sets. Using a.permission_set_arn in account_assignments before the permission sets have been applied will result in the following error. ``` Error: Invalid for_each argument on .terraform/modules/sso_account_assignments/modules/account-assignments/main.tf line 30, in resource "aws_ssoadmin_account_assignment" "this": 30: for_each = local.assignment_map 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. ``` Attempting to provide a unique (enough) value that is already predetermined before apply by adding a.permission_set_name instead of arn. Yes, its less unique but there should be only one assignment using the same account, principal, principal type, and permission set name. Yes, you are carrying 2 values over from the permission set (name and arn) instead of just one (arn). But it gets around the uniqueness problem. I couldnt think of any other good choice at the moment. Maybe someone else will come up with a better value. Maybe use a random_string.name.result?
I have been successful with a workaround that does not involve another arbitrary key, i have opened a PR, can you guys check it out before we make the compromise? #14 |
I'm happy with this solution. Although it's a new arbitrary key, you can see it as a description or comment of the assignment and it helps to have stable resource names which avoid unnecessary recreation of resources when the list is altered. |
/terraform-fmt |
Co-authored-by: Johannes Grumböck <johannes.grumboeck@redbull.com>
/test all |
Error: Invalid for_each argument
/test all |
I think |
This Pull Request has been updated, so we're dismissing all reviews.
🎉 |
what
why
references