From ab29eca045c1c1b4835689bc31bdcfaf9aecab83 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sun, 22 May 2016 07:55:39 -0700 Subject: [PATCH] core: don't force data resource id diff to be empty In an attempt to always show "id" as computed we were producing a synthetic diff for it, but this causes problems when the id attribute for a particular data source is actually settable in configuration, since it masks the setting from the config and forces it to always be empty. Instead, we'll set it conditionally so that a value provided in the config can shine through when available. --- terraform/eval_read_data.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/terraform/eval_read_data.go b/terraform/eval_read_data.go index aeb2ebaef..fb85a284e 100644 --- a/terraform/eval_read_data.go +++ b/terraform/eval_read_data.go @@ -47,14 +47,17 @@ func (n *EvalReadDataDiff) Eval(ctx EvalContext) (interface{}, error) { diff = new(InstanceDiff) } - // id is always computed, because we're always "creating a new resource" + // if id isn't explicitly set then it's always computed, because we're + // always "creating a new resource". diff.init() - diff.SetAttribute("id", &ResourceAttrDiff{ - Old: "", - NewComputed: true, - RequiresNew: true, - Type: DiffAttrOutput, - }) + if _, ok := diff.Attributes["id"]; !ok { + diff.SetAttribute("id", &ResourceAttrDiff{ + Old: "", + NewComputed: true, + RequiresNew: true, + Type: DiffAttrOutput, + }) + } } err = ctx.Hook(func(h Hook) (HookAction, error) {