-
Notifications
You must be signed in to change notification settings - Fork 233
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
Ability to Conditionally Mark Schema Attributes Sensitive #736
Comments
Thanks for the very detailed write-up, @bflad! I just wanted to chime in and note that your suspicions are correct, we would need an upstream Terraform change for this, as the protocol decides whether a field is Sensitive when retrieving the schema, and therefore that information is supposed to be static. To enable it to be dynamic, we'd need to figure out either how to make schemas dynamic (hard) or figure out a new way to communicate sensitivity to Terraform that allowed for it to be dynamic (open-ended). I think it's a really reasonable request, I just wanted to be clear on why it's blocked at the moment. I've labeled it accordingly, and will make sure the feedback gets to the Terraform team, to get it on their radar. |
Some additionally good news here is that the upstream issue with provider-based sensitive values not being able to be unmarked via the |
Modern Terraform versions now treat sensitivity as a dynamic characteristic that can flow between expressions in the same sense that "unknown" is, so the good news here is that I think the overall Terraform language is ready to support something like this. The main challenge here then, I believe, is defining a backward-compatible way for sensitivity to traverse the provider plugin wire protocol, both into and out of operations like Related to that, although then more the concern of the SDK itself rather than Terraform, is to think about to what extent provider code should interact with sensitive values. The most ideal thing would be for providers to preserve transitive sensitivity in the same way that the Terraform language does, so that e.g. if I set the That's a pretty disruptive, cross-cutting requirement though... provider code typically wants to convert Terraform language values into more conventional Go types, act on them, and then convert back to the Terraform type system on the way out, but that runs into similar challenges as we have with unknown values during It was for these reasons that our first iteration of sensitivity left the provider-side model of sensitivity still static and based on schema: that avoided imposing any new burdens on the SDK or on individual provider codebases, while still getting a reasonable compromise behavior. I expect we can find reasonable answers/compromises for these questions, and so I'm not intending this comment as rejecting the proposal but rather as some additional context that I hope will help inform the next level of design. |
I think that we probably won't ever get to perfect support here if it were dynamically addressable via providers--as @apparentlymart pointed out, provider values too frequently become Go values that lose this information. But I think we could support it in the same way we do unknown values in the framework at the very least, making it part of the |
I expect that for backward compatibility with existing providers Terraform Core would need to continue being responsible for handling the static If we don't have that opt-out then I guess Terraform Core would mark the value as sensitive if the schema says so OR if the dynamic provider response says so, with the logical meaning of OR such that the static declaration being Because there's no standard representation of this idea of "sensitive" in either JSON or msgpack, thus far Terraform Core has always serialized sensitivity marks as a sidecar data structure using attribute paths. That works in most cases, but it does have some rough edges in the same places that our other uses of attribute paths do, such as there being no way to represent traversing into a set and selecting a specific element. (In practice that's not really important for sensitive in particular, because individual set elements can't be sensitive anyway.) With that said then, perhaps we could prototype what it would look like to add some optional new fields in the protobuf specification to carry the sensitivity information alongside the values. I don't know yet whether it would make more sense to add them to each of the relevant |
I haven't seen all the possible places where this can be an issue. However, I can give the context of one place. A list (or set) of name/value pairs. If name (or type) is |
Please Note: This issue is being submitted in the absence of an existing one I could find and meant more for gathering other use cases and/or showing an explicit decision on the subject. Especially in Terraform CLI 0.15 and later, most practitioners can and probably should use
sensitive = true
variable blocks or thesensitive()
function to explicitly enable sensitive value handling where it is not present in providers. Conversely, thenonsensitive()
function can be used to workaround provider-based sensitive values in downstream references as necessary. There is potential for this issue to be moot for code enhancements (except maybe comments around the helper/schema.Schema Sensitive field), but maybe left as tracking towards documentation and education efforts.SDK version
Use-cases
Currently, the Terraform Plugin SDK does not provide functionality to conditionally mark or unmark sensitive attributes. In numerous cases, provider developers have had to compromise by marking certain attributes with
Sensitive: true
in their schema while the value may not be always sensitive based on other resource configuration. When a provider attribute, especially in Terraform CLI 0.15 and later, is marked sensitive, but does not actually have a sensitive value, it has a lot of user experience consequences, including:output
blocks to includesensitive = true
or wrap sensitive values with thenonsensitive()
function. This may not be intuitive since it previously worked fine for practitioners.For a canonical AWS Provider example, see the
aws_ssm_parameter
resource, which accepts aString
type orSecureString
type for the parameter. It is currently set asSensitive: true
. I'll reference other issues/resources below where we have seen this request for conditional sensitivity in the AWS Provider as well.Attempted Solutions
In the AWS Provider example, debating on whether to create a separate "sensitive"/
SecureString
resource:Proposal
Enhance the SDK (presumably after Terraform CLI and Terraform Plugin Protocol changes) to support conditional sensitivity on attributes, similar to how
ForceNew
can be applied conditionally.References
secure
flag)The text was updated successfully, but these errors were encountered: