Is there any way of implementing this functionality within a plugin so that there’s an implicit dependency between resources?
As an example, in the snowflake provider there is a resource snowflake_procedure and resource snowflake_procedure_grant. Whenever a change forces replacement of the snowflake_procedure resource the snowflake_procedure_grant resource should also be replaced.
replace_triggered_by does work for this use case however, if there’s a way to define that relationship directly in the plugin then that’d be even better.
Providers only see one resource instance at a time so cannot directly implement rules such as “if object A is replaced then also replace object B”.
However, it’s often (but not always) possible to achieve that effect by careful provider design. For example, if there’s some attribute that gets included in the downstream resource to connect it with the upstream one then the upstream one can report that attribute is changing as part of its plan and then the downstream one can see that change and take whatever action makes sense, such as reporting that the change requires the object to be replaced.
1 Like