@@ -91,9 +91,9 @@ func (h *moduleHandler) Diff(
91
91
return nil , err
92
92
}
93
93
94
+ inputsChanged := false
94
95
if ! oldInputs .DeepEquals (newInputs ) {
95
- // Inputs have changed, so we need tell the engine that an update is needed.
96
- return & pulumirpc.DiffResponse {Changes : pulumirpc .DiffResponse_DIFF_SOME }, nil
96
+ inputsChanged = true
97
97
}
98
98
99
99
// Here, inputs have not changes but the underlying module might have changed
@@ -106,7 +106,7 @@ func (h *moduleHandler) Diff(
106
106
tf , err := h .prepSandbox (
107
107
ctx ,
108
108
urn ,
109
- oldInputs ,
109
+ newInputs ,
110
110
oldOutputs ,
111
111
inferredModule ,
112
112
moduleSource ,
@@ -123,12 +123,19 @@ func (h *moduleHandler) Diff(
123
123
return nil , fmt .Errorf ("error performing plan during Diff(...) %w" , err )
124
124
}
125
125
126
+ replaceKeys := []string {}
126
127
resourcesChanged := false
127
- plan .VisitResourcePlans (func (resource * tfsandbox.ResourcePlan ) {
128
- if resource .ChangeKind () != tfsandbox .NoOp {
128
+ plan .VisitResourcePlans (func (res * tfsandbox.ResourcePlan ) {
129
+ println ("Visiting resource plan for" , res .Address ())
130
+ println ("Change kind is" , res .ChangeKind ())
131
+ if res .ChangeKind () != tfsandbox .NoOp {
129
132
// if there is any resource change that is not a no-op, we need to update.
130
133
resourcesChanged = true
131
134
}
135
+ // Add any resources that are replacing to the replaceKeys list.
136
+ if res .ChangeKind () == tfsandbox .Replace || res .ChangeKind () == tfsandbox .ReplaceDestroyBeforeCreate {
137
+ replaceKeys = append (replaceKeys , string (res .Address ()))
138
+ }
132
139
})
133
140
134
141
outputsChanged := false
@@ -139,8 +146,16 @@ func (h *moduleHandler) Diff(
139
146
}
140
147
}
141
148
142
- if resourcesChanged || outputsChanged {
143
- return & pulumirpc.DiffResponse {Changes : pulumirpc .DiffResponse_DIFF_SOME }, nil
149
+ println ("Is it DIFF_SOME?" , inputsChanged || resourcesChanged || outputsChanged )
150
+ println ("inputsChanged?" , inputsChanged )
151
+ println ("resourcesChanged?" , resourcesChanged )
152
+ println ("outputsChanged?" , outputsChanged )
153
+
154
+ if inputsChanged || resourcesChanged || outputsChanged {
155
+ return & pulumirpc.DiffResponse {
156
+ Changes : pulumirpc .DiffResponse_DIFF_SOME ,
157
+ Replaces : replaceKeys ,
158
+ }, nil
144
159
}
145
160
146
161
// the module has not changed, return DIFF_NONE.
0 commit comments