diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 58c61a393..c74dddfcd 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -9002,15 +9002,14 @@ func TestContext2Apply_ignoreChangesWildcard(t *testing.T) { }) if p, diags := ctx.Plan(); diags.HasErrors() { - t.Fatalf("diags: %s", diags.Err()) + logDiagnostics(t, diags) + t.Fatal("plan failed") } else { t.Logf(legacyDiffComparisonString(p.Changes)) } state, diags := ctx.Apply() - if diags.HasErrors() { - t.Fatalf("diags: %s", diags.Err()) - } + assertNoErrors(t, diags) mod := state.RootModule() if len(mod.Resources) != 1 { diff --git a/terraform/eval_diff.go b/terraform/eval_diff.go index 6f0dccfb4..40f89e56a 100644 --- a/terraform/eval_diff.go +++ b/terraform/eval_diff.go @@ -415,6 +415,12 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) { } func (n *EvalDiff) processIgnoreChanges(schema *configschema.Block, prior, proposed cty.Value) (cty.Value, tfdiags.Diagnostics) { + // ignore_changes only applies when an object already exists, since we + // can't ignore changes to a thing we've not created yet. + if prior.IsNull() { + return proposed, nil + } + ignoreChanges := n.Config.Managed.IgnoreChanges ignoreAll := n.Config.Managed.IgnoreAllChanges