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.
This commit is contained in:
Pam Selle 2020-09-08 12:49:39 -04:00
parent b03d5df9dc
commit 712f5a5cc3
2 changed files with 9 additions and 11 deletions

View File

@ -247,13 +247,6 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) {
} }
plannedNewVal := resp.PlannedState plannedNewVal := resp.PlannedState
// Add the marks back to the planned new value
markedPlannedNewVal := plannedNewVal
if configVal.ContainsMarked() {
markedPlannedNewVal = plannedNewVal.MarkWithPaths(unmarkedPaths)
}
plannedPrivate := resp.PlannedPrivate plannedPrivate := resp.PlannedPrivate
if plannedNewVal == cty.NilVal { 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 // Call post-refresh hook
if !n.Stub { if !n.Stub {
err := ctx.Hook(func(h Hook) (HookAction, error) { err := ctx.Hook(func(h Hook) (HookAction, error) {
@ -499,10 +497,10 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) {
Change: plans.Change{ Change: plans.Change{
Action: action, Action: action,
Before: priorVal, Before: priorVal,
// Pass the marked value through in our change // Pass the marked planned value through in our change
// to propogate through evaluation. // to propogate through evaluation.
// Marks will be removed when encoding. // Marks will be removed when encoding.
After: markedPlannedNewVal, After: plannedNewVal,
}, },
RequiredReplace: reqRep, RequiredReplace: reqRep,
} }

View File

@ -1,9 +1,9 @@
variable "foo" {} variable "foo" {}
resource "aws_instance" "foo" { resource "aws_instance" "foo" {
ami = "${var.foo}" ami = var.foo
lifecycle { lifecycle {
ignore_changes = ["ami"] ignore_changes = [ami]
} }
} }