@@ -127,9 +127,9 @@ func (h *moduleHandler) Diff(
127
127
return nil , err
128
128
}
129
129
130
+ inputsChanged := false
130
131
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
133
133
}
134
134
135
135
// Here, inputs have not changes but the underlying module might have changed
@@ -142,7 +142,7 @@ func (h *moduleHandler) Diff(
142
142
tf , err := h .prepSandbox (
143
143
ctx ,
144
144
urn ,
145
- oldInputs ,
145
+ newInputs ,
146
146
oldOutputs ,
147
147
inferredModule ,
148
148
moduleSource ,
@@ -159,12 +159,19 @@ func (h *moduleHandler) Diff(
159
159
return nil , fmt .Errorf ("error performing plan during Diff(...) %w" , err )
160
160
}
161
161
162
+ replaceKeys := []string {}
162
163
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 {
165
168
// if there is any resource change that is not a no-op, we need to update.
166
169
resourcesChanged = true
167
170
}
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
+ }
168
175
})
169
176
170
177
outputsChanged := false
@@ -175,8 +182,16 @@ func (h *moduleHandler) Diff(
175
182
}
176
183
}
177
184
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
180
195
}
181
196
182
197
// the module has not changed, return DIFF_NONE.
0 commit comments