core: Skip ignore_changes handling for create actions
It doesn't make sense to ignore_changes when the prior value is null, since we have to create something before we can ignore changes to it. This change is verified by TestContext2Apply_ignoreChangesWildcard.
This commit is contained in:
parent
5c4545dac2
commit
9e0f7c10d9
|
@ -9002,15 +9002,14 @@ func TestContext2Apply_ignoreChangesWildcard(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
if p, diags := ctx.Plan(); diags.HasErrors() {
|
if p, diags := ctx.Plan(); diags.HasErrors() {
|
||||||
t.Fatalf("diags: %s", diags.Err())
|
logDiagnostics(t, diags)
|
||||||
|
t.Fatal("plan failed")
|
||||||
} else {
|
} else {
|
||||||
t.Logf(legacyDiffComparisonString(p.Changes))
|
t.Logf(legacyDiffComparisonString(p.Changes))
|
||||||
}
|
}
|
||||||
|
|
||||||
state, diags := ctx.Apply()
|
state, diags := ctx.Apply()
|
||||||
if diags.HasErrors() {
|
assertNoErrors(t, diags)
|
||||||
t.Fatalf("diags: %s", diags.Err())
|
|
||||||
}
|
|
||||||
|
|
||||||
mod := state.RootModule()
|
mod := state.RootModule()
|
||||||
if len(mod.Resources) != 1 {
|
if len(mod.Resources) != 1 {
|
||||||
|
|
|
@ -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) {
|
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
|
ignoreChanges := n.Config.Managed.IgnoreChanges
|
||||||
ignoreAll := n.Config.Managed.IgnoreAllChanges
|
ignoreAll := n.Config.Managed.IgnoreAllChanges
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue