ext/dynblock: Allow callers to veto for_each values #634
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.
Callers might have additional rules for what's acceptable in a
for_each
value for a dynamic block. For example, Terraform wants to forbid using sensitive values here because it would cause the expansion to disclose the length of the given collection, but currently ends up returning a very low-quality (highly misleading) error in that case, as discussed in hashicorp/terraform#29744 .Therefore this provides a hook point for callers to insert additional checks just after the for_each expression has been evaluated and before any of the built-in checks are run. Terraform can use this to check whether the
for_each
value is sensitive, and if so to return a specialized error about that which:for_each
expression.This would therefore allow a future change to Terraform itself to make it return a helpful error message in this situation, similar to the one it already returns for its own
for_each
features in the same situation.This introduces the "functional options" pattern for
dynblock.ExpandBlock
for the first time, as a way to extend the API without breaking compatibility with existing callers. There is currently only this one option.