@@ -127,9 +127,9 @@ func (h *moduleHandler) Diff(
127127 return nil , err
128128 }
129129
130+ inputsChanged := false
130131 if ! oldInputs .DeepEquals (newInputs ) {
131- // Inputs have changed, so we need tell the engine that an update is needed.
132- return & pulumirpc.DiffResponse {Changes : pulumirpc .DiffResponse_DIFF_SOME }, nil
132+ inputsChanged = true
133133 }
134134
135135 // Here, inputs have not changes but the underlying module might have changed
@@ -142,7 +142,7 @@ func (h *moduleHandler) Diff(
142142 tf , err := h .prepSandbox (
143143 ctx ,
144144 urn ,
145- oldInputs ,
145+ newInputs ,
146146 oldOutputs ,
147147 inferredModule ,
148148 moduleSource ,
@@ -159,12 +159,19 @@ func (h *moduleHandler) Diff(
159159 return nil , fmt .Errorf ("error performing plan during Diff(...) %w" , err )
160160 }
161161
162+ replaceKeys := []string {}
162163 resourcesChanged := false
163- plan .VisitResourcePlans (func (resource * tfsandbox.ResourcePlan ) {
164- if resource .ChangeKind () != tfsandbox .NoOp {
164+ plan .VisitResourcePlans (func (res * tfsandbox.ResourcePlan ) {
165+ println ("Visiting resource plan for" , res .Address ())
166+ println ("Change kind is" , res .ChangeKind ())
167+ if res .ChangeKind () != tfsandbox .NoOp {
165168 // if there is any resource change that is not a no-op, we need to update.
166169 resourcesChanged = true
167170 }
171+ // Add any resources that are replacing to the replaceKeys list.
172+ if res .ChangeKind () == tfsandbox .Replace || res .ChangeKind () == tfsandbox .ReplaceDestroyBeforeCreate {
173+ replaceKeys = append (replaceKeys , string (res .Address ()))
174+ }
168175 })
169176
170177 outputsChanged := false
@@ -175,8 +182,16 @@ func (h *moduleHandler) Diff(
175182 }
176183 }
177184
178- if resourcesChanged || outputsChanged {
179- return & pulumirpc.DiffResponse {Changes : pulumirpc .DiffResponse_DIFF_SOME }, nil
185+ println ("Is it DIFF_SOME?" , inputsChanged || resourcesChanged || outputsChanged )
186+ println ("inputsChanged?" , inputsChanged )
187+ println ("resourcesChanged?" , resourcesChanged )
188+ println ("outputsChanged?" , outputsChanged )
189+
190+ if inputsChanged || resourcesChanged || outputsChanged {
191+ return & pulumirpc.DiffResponse {
192+ Changes : pulumirpc .DiffResponse_DIFF_SOME ,
193+ Replaces : replaceKeys ,
194+ }, nil
180195 }
181196
182197 // the module has not changed, return DIFF_NONE.
0 commit comments