-
Notifications
You must be signed in to change notification settings - Fork 93
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
Run plan modifiers from bottom to top for nested objects #974
Comments
I would like to know if there is a reason that it is done this way and how I can implement my schema that I define top level attribute as RequiresReplace but it doesn't affect computed fields. |
Hey @nickexported, I can't help with your problem, but I'm tickled to see the copperfield provider show up here :) |
Hey there @nickexported 👋🏻 , thanks for reporting the bug and sorry you're running into trouble here. I've been trying to recreate this issue with the schema provided and a small sandbox example using it, see:
I'm not able to recreate the behavior you're describing, so I might need more information about your resource code. (CRUD methods, any other plan modification at the resource level, etc.) Perhaps you can take a look at the sandbox example I provided and see if I'm missing anything there. Your interpretation of the framework plan modification logic is correct, the object in this scenario will be marked as Can you also share what version of Terraform you're running into this issue with? Perhaps there is a bug somewhere else down the line.... I've been using |
I think I have a similar problem when using
schema
In my case. I find the When I remove the It seems the PlanModifiers defined in the netsed attributes do not work. |
Module version
Use-cases
Consider following schema.
After apply of following config
I get state:
Now I want to update resource with following config:
And now terraform wants to recreate this reource because of unknown value for computed, however I configured field computed to use state for unknow. That is a bit frustrating and unexpected behaviour.
The key is in ths function https://github.com/hashicorp/terraform-plugin-framework/blob/main/internal/fwserver/attribute_plan_modification.go#L85 What it does is that it runs plan modifier for top level object and only after that for nested object, but at that time objectplanmodifier.RequiresReplace() has already marked resource for recreate.
Attempted Solutions
I would suggest to modify function AttributeModifyPlan so it checks if this object has nested objects and if true applies plan modifiers for nested objects, and only after that proceeds to it's own plan modifiers.
Proposal
Basically I suggest to put switch case after nested attribute object
References
The text was updated successfully, but these errors were encountered: