-
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
ForceNew doesn't trigger resource recreation when defined on TypeSet, which leads to Update error #34691
Comments
Thanks for reporting this, @annakhm! I think the first thing we'll need to do here is figure out whether the behavior you've described belongs to Terraform Core or to the plugin SDK. I suspect the latter, because There must presumably therefore be some logic in the SDK which checks the It's been a long time since I personally worked on the SDK so I don't really remember my way around that codebase anymore, but I did find at least one location where it seems to be doing a If we can determine (with more certainty than I can currently muster) that this is a limitation of the SDK logic then we should probably move this issue over to the SDK repository, but I don't yet feel confident enough to do that based on my initial analysis here. Unfortunately if this is an SDK limitation then the outcome is likely to be only to document the limitation more clearly, since the development priority for the SDK is now only to keep existing providers working the same way they always did, and not to introduce any new capabilities. |
Thank you for looking at this so quickly @apparentlymart! I was indeed having my doubts on whether to post this under sdk or terraform core, since both seem to implement a portion the |
Yes, I see what you mean, I would expect |
The rule about requiring everything to have As a general rule, Terraform Core will always save the new state returned by the provider -- even if the provider also indicates an error -- because some providers are capable of a sort of "partial success", where perhaps the IIRC providers are allowed to leave the "new state" totally unset when they return an error, in which case Terraform Core would just retain the prior state on the assumption that the failure was so severe that the provider can't even describe what the situation is. However, I don't think the SDK offers a direct way to do that, because the SDK uses a design where the provider is directly mutating the planned new state (using All of that said then: I think the behavior of updating the state is Terraform Core working as designed -- it's saving what the provide returned -- but it's debatable whether the provider (i.e. the SDK) should've returned an object at all if the provider-side situation was so invalid that it couldn't even call the |
Thanks @apparentlymart. Sounds like I should move this issue to SDK then :) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/annakhm/60101ee4667f879d650a017b00418121
Expected Behavior
The resource should be recreated since
roles_for_path
is defined asForceNew
Actual Behavior
The resource is not recreated. Update fails with
Error: doesn't support update
(since Update function is not defined)The new value is recorded in the state although the update didn't happen:
Steps to Reproduce
Update
function.roles = ["test-value-1"]
toroles = ["test-value-2"]
Additional Context
My understanding is that any change in aggregate attribute (
TypeList
orTypeSet
) should trigger resource recreation. Looks like its not the case. DefiningForceNew
onroles
attribute is fixing the issue.If
ForceNew
onTypeSet
is meaningless and was designed to only define behavior of basic types, then we have a problem with validation ofUpdate
function availability. Terraform would complain that we can omitUpdate
function only if every attribute isForceNew
.Even if the behavior explained above is expected, it feels like updating the intent value in state without success in
Update
is not intended behavior.References
No response
The text was updated successfully, but these errors were encountered: