terraform_data write-only and sensitive extensions#38298
Draft
terraform_data write-only and sensitive extensions#38298
Conversation
Contributor
Changelog WarningCurrently this PR would target a v1.16 release. Please add a changelog entry for in the .changes/v1.16 folder, or discuss which release you'd like to target with your reviewer. If you believe this change does not need a changelog entry, please add the 'no-changelog-needed' label. |
Add a new object to the terraform_data resource to handle sensitive and write-only attributes. The new `store` object has input and output values, which work much like the top-level input and output. The difference is that the `store.input` is truly "write only" and can also accept ephemeral values. Additional arguments for the `store` object are: - `version`, allows the user to determine exactly when the input value will be replaced in `store.output`. - `sensitive`, conditionally directs the stored value between `output` or `sensitive_output`. - `replace` signals that any change to either output should trigger replacement of the entire resource.
Update a stacks test to ensure we create up-to-date values for the terraform_data resource. We also remove the encoded test values for easier reading. Update the copy of the schema necessary for the rpcapi test
a38dd9d to
b477351
Compare
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.
Add new new
storeobject to theterraform_dataresource, which acts much like the top level resource, but can accept ephemeral value, and choose whether to mask the output as sensitive.The
storeblockinputattribute is write-only, meaning that it can accept ephemeral value, as well as non ephemeral values, allowing the user to store anything in the corresponding output. The default behavior assumes a relatively stable input value, and will automatically plan the replacement of anoutputvalue when they do not match. An optionalversionattribute lets the user manually choose when to update the store outputs.The optional
sensitiveattribute moves the stored value to thesensitive_outputattribute, which is unsurprisingly defined as sensitive in the resource schema.The optional
replaceattribute indicates that the entire resource should be replace when there is an update to either thestoreoutputorsensitive_outputvalue.While this is a change to the resource schema, we do not version this change in the schema. If the schema were versioned, because this is a builtin provider, the schema upgrade would lock users into an upgraded terraform version, and prevent them from rolling back in the case of a critical bug. Since the schema upgrade does not need to restructure any of the data, we can insert new block during the upgrade, and just let it be removed silently in the case of a downgrade.
An example of using the new
storeblockThis will store the ephemeral password seen during apply in the output value
With the result:
Even though the random password will change on every plan and apply,
terraform_data.testwill remain stable until theversionattribute is changed to some other value. Onceversionis changed, theoutputattribute will have a planned change, and thereplaceattribute will cause the resource to be recreated.