Moving the conditional out of the for_each #2388
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently by having the conditional check in the for_each terraform will fail to plan with the dreaded "Error: Invalid for_each argument" error. This happens even if you are not trying to use the module provided role. Moving the conditional check out allows terraform to plan successfully.
Motivation and Context
#2337
Breaking Changes
No
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectsI have added the following to the bottom of the examples/eks_managed_node_group/main.tf
With the above, the example continues to plan successfully. In my env, the PR change allows me to successfully plan and create a cluster while the previous code caused a for_each plan failure.
pre-commit run -a
on my pull request