-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Ensure WriteOnly attributes are rejected as non-ephemeral output
values
#36171
Conversation
5e45d66
to
be96750
Compare
eee275f
to
fda482c
Compare
be96750
to
7689c9b
Compare
The equivalence tests will be updated. Please verify the changes here. |
Note that this falls into the same trap as trying to validate deprecated attributes and outputs (#36016 (comment)), a large portion of attribute use is indirect and won't be detected, or will cause false positives. |
That explains why in the current implementation the diagnostics only come up later during I mean, ephemerality is driven through marks and marks get assigned to values, specifically only the values which are in fact ephemeral. IMHO lack of detection in some cases would be fine but of course false positives would not. Can you think of some specific examples of false positives in the context of WriteOnly attributes? |
7689c9b
to
14c36f3
Compare
Write-only is also only determined by the schema, just like deprecated. Parts of this PR are searching for ephemeral marks in changes, but ephemeral marks cannot make it all the way through to the plan at all (and ephemeral marks do not correspond 1-1 with write-only attributes). The only place an ephemeral value can be assigned within a resource's config is to a write-only attribute, but that is write-only, and cannot pass through any value to the state or plan. The result of evaluating a write-only attribute is always The failure mode is the same as in the comment I linked. The result of evaluating any reference to something which can have multiple instances is the entire container, so a reference like
The output value expression here is just calling |
we might need them later on, but it will be easier to find the right place and abstraction when the need to use them arises
we got the marks from the proposed value, the provider gets the value without the marks we then reapply the marks and need to also remove the write-only values by setting the values to null
we allow it for all requests
fda482c
to
aee7e70
Compare
14c36f3
to
da75375
Compare
The equivalence tests will be updated. Please verify the changes here. |
Using that example above, I can confirm that the current implementation does validate it as expected, as far as I can tell: resource "terraform_example" "test" {
foo = "foo"
wo_attr = "noot"
}
locals {
foo = terraform_example.test
}
output "out" {
value = local.foo.wo_attr
}
I also added a commit that modifies the builtin Again - I can understand this won't cover 100% of all cases and cannot be relied on but I'm still struggling to understand how it could treat valid configuration as invalid?
I'd be fine with creating a dedicated WriteOnly mark if we deem it necessary but I take that more as an implementation detail compared to the rest.
That is true but I do not see how that's in conflict with anything. I mean, marks can still be assigned and passed around along with a null value, can they not? |
aee7e70
to
3a962e8
Compare
Previously the following configuration would pass validation. The value was still
null
so it wasn't a big deal from the perspective of broken promises but it would be confusing for the user.This PR makes it so it is rejected the same way as other existing ephemeral values.
This builds on top of #36031