diff --git a/builtin/providers/test/data_source.go b/builtin/providers/test/data_source.go index 0ad5b5ad49..3c34b96836 100644 --- a/builtin/providers/test/data_source.go +++ b/builtin/providers/test/data_source.go @@ -26,6 +26,11 @@ func testDataSource() *schema.Resource { Type: schema.TypeString, Computed: true, }, + // this attribute is computed, but never set by the provider + "nil": { + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/builtin/providers/test/data_source_test.go b/builtin/providers/test/data_source_test.go index 2ff2ca7706..009aec5cd0 100644 --- a/builtin/providers/test/data_source_test.go +++ b/builtin/providers/test/data_source_test.go @@ -155,3 +155,37 @@ data "test_data_source" "baz" { input = "${data.test_data_source.bar.*.output[count.index]}" } ` + +func TestDataSource_nilComputedValues(t *testing.T) { + check := func(s *terraform.State) error { + return nil + } + + resource.UnitTest(t, resource.TestCase{ + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Check: check, + Config: ` +variable "index" { + default = "d" +} + +locals { + name = { + a = "something" + b = "else" + } +} + +data "test_data_source" "x" { + input = "${lookup(local.name, var.index, local.name["a"])}" +} + +data "test_data_source" "y" { + input = data.test_data_source.x.nil == "something" ? "something" : "else" +}`, + }, + }, + }) +}