From 3800dffdeb75b9f255be0bac6b37b3ce27c93bf4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 18 Aug 2014 15:10:53 -0700 Subject: [PATCH] helper/schema: computed values should not be Get-able --- helper/schema/resource_data.go | 2 +- helper/schema/resource_data_test.go | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/helper/schema/resource_data.go b/helper/schema/resource_data.go index 0b75f16dc..d2f662884 100644 --- a/helper/schema/resource_data.go +++ b/helper/schema/resource_data.go @@ -273,7 +273,7 @@ func (d *ResourceData) getPrimitive( if d.diff != nil && source >= getSourceDiff { attrD, ok := d.diff.Attributes[k] - if ok { + if ok && !attrD.NewComputed { result = attrD.New resultSet = true } diff --git a/helper/schema/resource_data_test.go b/helper/schema/resource_data_test.go index 0ec7832cb..a0698dd07 100644 --- a/helper/schema/resource_data_test.go +++ b/helper/schema/resource_data_test.go @@ -15,6 +15,33 @@ func TestResourceDataGet(t *testing.T) { Key string Value interface{} }{ + { + Schema: map[string]*Schema{ + "availability_zone": &Schema{ + Type: TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + + State: nil, + + Diff: &terraform.ResourceDiff{ + Attributes: map[string]*terraform.ResourceAttrDiff{ + "availability_zone": &terraform.ResourceAttrDiff{ + Old: "", + New: "", + NewComputed: true, + }, + }, + }, + + Key: "availability_zone", + + Value: nil, + }, + { Schema: map[string]*Schema{ "availability_zone": &Schema{