ext/dynblock: Allow callers to veto for_each values#634
Merged
apparentlymart merged 1 commit intomainfrom Oct 16, 2023
Merged
Conversation
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. 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. This introduces the "functional options" pattern for 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.
jbardin
approved these changes
Oct 16, 2023
Contributor
Author
|
(Just for the sake of creating a backlink in GitHub.) This also includes a new building block that we can use to resolve hashicorp/terraform#29744 by implementing a Terraform-specific error message about sensitive values in the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_eachvalue 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_eachvalue is sensitive, and if so to return a specialized error about that which:for_eachexpression.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_eachfeatures in the same situation.This introduces the "functional options" pattern for
dynblock.ExpandBlockfor the first time, as a way to extend the API without breaking compatibility with existing callers. There is currently only this one option.