diff --git a/command/format/plan.go b/command/format/plan.go index a2a49c303..e02190f9e 100644 --- a/command/format/plan.go +++ b/command/format/plan.go @@ -91,6 +91,8 @@ func NewPlan(changes *plans.Changes) *Plan { } switch rc.Action { + case plans.NoOp: + continue case plans.Create: if dataSource { // Use "refresh" as the action for display, but core diff --git a/helper/plugin/grpc_provider.go b/helper/plugin/grpc_provider.go index 0c8417460..be3bbc61f 100644 --- a/helper/plugin/grpc_provider.go +++ b/helper/plugin/grpc_provider.go @@ -386,6 +386,15 @@ func (s *GRPCProviderServer) PlanResourceChange(_ context.Context, req *proto.Pl return resp, nil } + if diff == nil { + // schema.Provider.Diff returns nil if it ends up making a diff with + // no changes, but our new interface wants us to return an actual + // change description that _shows_ there are no changes, so we need + // to synthesize one here. + resp.PlannedState = req.PriorState + return resp, nil + } + // now we need to apply the diff to the prior state, so get the planned state plannedStateVal, err := schema.ApplyDiff(priorStateVal, diff, block) if err != nil { diff --git a/plugin/grpc_provider.go b/plugin/grpc_provider.go index 6d8cfe65c..3b066258d 100644 --- a/plugin/grpc_provider.go +++ b/plugin/grpc_provider.go @@ -6,6 +6,8 @@ import ( "log" "sync" + "github.com/zclconf/go-cty/cty" + plugin "github.com/hashicorp/go-plugin" "github.com/hashicorp/terraform/plugin/convert" "github.com/hashicorp/terraform/plugin/proto" @@ -398,14 +400,17 @@ func (p *GRPCProvider) ApplyResourceChange(r providers.ApplyResourceChangeReques resp.Private = protoResp.Private - state, err := msgpack.Unmarshal(protoResp.NewState.Msgpack, resSchema.Block.ImpliedType()) - if err != nil { - resp.Diagnostics = resp.Diagnostics.Append(err) - return resp + if protoResp.NewState != nil { + state, err := msgpack.Unmarshal(protoResp.NewState.Msgpack, resSchema.Block.ImpliedType()) + if err != nil { + resp.Diagnostics = resp.Diagnostics.Append(err) + return resp + } + resp.NewState = state + } else { + resp.NewState = cty.NullVal(resSchema.Block.ImpliedType()) } - resp.NewState = state - return resp } diff --git a/terraform/transform_diff.go b/terraform/transform_diff.go index 67a94fed9..f22c17f7b 100644 --- a/terraform/transform_diff.go +++ b/terraform/transform_diff.go @@ -34,6 +34,8 @@ func (t *DiffTransformer) Transform(g *Graph) error { // other actions. var update, delete bool switch rc.Action { + case plans.NoOp: + continue case plans.Delete: delete = true case plans.Replace: