From 712f5a5cc36b1600e9f42c776b1d8db4b3370f78 Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Tue, 8 Sep 2020 12:49:39 -0400 Subject: [PATCH] Update plannedNewVal itself Using markedPlannedNewVal caused many test failures with ignoreChanges, and I noted plannedNewVal itself is modified in the eval_diff. plannedNewVal is now marked closer to the change where it needs it. There is also a test fixture update to remove interpolation warnings. --- terraform/eval_diff.go | 16 +++++++--------- terraform/testdata/plan-ignore-changes/main.tf | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/terraform/eval_diff.go b/terraform/eval_diff.go index 78d1522558..ac3f3ca6bb 100644 --- a/terraform/eval_diff.go +++ b/terraform/eval_diff.go @@ -247,13 +247,6 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) { } plannedNewVal := resp.PlannedState - - // Add the marks back to the planned new value - markedPlannedNewVal := plannedNewVal - if configVal.ContainsMarked() { - markedPlannedNewVal = plannedNewVal.MarkWithPaths(unmarkedPaths) - } - plannedPrivate := resp.PlannedPrivate if plannedNewVal == cty.NilVal { @@ -480,6 +473,11 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) { } } + // Add the marks back to the planned new value + if configVal.ContainsMarked() { + plannedNewVal = plannedNewVal.MarkWithPaths(unmarkedPaths) + } + // Call post-refresh hook if !n.Stub { err := ctx.Hook(func(h Hook) (HookAction, error) { @@ -499,10 +497,10 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) { Change: plans.Change{ Action: action, Before: priorVal, - // Pass the marked value through in our change + // Pass the marked planned value through in our change // to propogate through evaluation. // Marks will be removed when encoding. - After: markedPlannedNewVal, + After: plannedNewVal, }, RequiredReplace: reqRep, } diff --git a/terraform/testdata/plan-ignore-changes/main.tf b/terraform/testdata/plan-ignore-changes/main.tf index 056256a1d8..ed17c63449 100644 --- a/terraform/testdata/plan-ignore-changes/main.tf +++ b/terraform/testdata/plan-ignore-changes/main.tf @@ -1,9 +1,9 @@ variable "foo" {} resource "aws_instance" "foo" { - ami = "${var.foo}" + ami = var.foo lifecycle { - ignore_changes = ["ami"] + ignore_changes = [ami] } }