|
|
|
|
@ -5,6 +5,7 @@ import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
|
ctyconvert "github.com/zclconf/go-cty/cty/convert"
|
|
|
|
|
@ -845,6 +846,7 @@ func (s *GRPCProviderServer) ApplyResourceChange(_ context.Context, req *proto.A
|
|
|
|
|
diff.Meta = private
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var newRemoved []string
|
|
|
|
|
for k, d := range diff.Attributes {
|
|
|
|
|
// We need to turn off any RequiresNew. There could be attributes
|
|
|
|
|
// without changes in here inserted by helper/schema, but if they have
|
|
|
|
|
@ -852,8 +854,10 @@ func (s *GRPCProviderServer) ApplyResourceChange(_ context.Context, req *proto.A
|
|
|
|
|
d.RequiresNew = false
|
|
|
|
|
|
|
|
|
|
// Check that any "removed" attributes that don't actually exist in the
|
|
|
|
|
// prior state, or helper/schema will confuse itself
|
|
|
|
|
// prior state, or helper/schema will confuse itself, and record them
|
|
|
|
|
// to make sure they are actually removed from the state.
|
|
|
|
|
if d.NewRemoved {
|
|
|
|
|
newRemoved = append(newRemoved, k)
|
|
|
|
|
if _, ok := priorState.Attributes[k]; !ok {
|
|
|
|
|
delete(diff.Attributes, k)
|
|
|
|
|
}
|
|
|
|
|
@ -882,6 +886,19 @@ func (s *GRPCProviderServer) ApplyResourceChange(_ context.Context, req *proto.A
|
|
|
|
|
return resp, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Now remove any primitive zero values that were left from NewRemoved
|
|
|
|
|
// attributes. Any attempt to reconcile more complex structures to the best
|
|
|
|
|
// of our abilities happens in normalizeNullValues.
|
|
|
|
|
for _, r := range newRemoved {
|
|
|
|
|
if strings.HasSuffix(r, ".#") || strings.HasSuffix(r, ".%") {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
switch newInstanceState.Attributes[r] {
|
|
|
|
|
case "", "0", "false":
|
|
|
|
|
delete(newInstanceState.Attributes, r)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We keep the null val if we destroyed the resource, otherwise build the
|
|
|
|
|
// entire object, even if the new state was nil.
|
|
|
|
|
newStateVal, err = schema.StateValueFromInstanceState(newInstanceState, schemaBlock.ImpliedType())
|
|
|
|
|
|