From e0b2c646454b77f311c9517a23ac642e2bbe4903 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 6 Dec 2017 18:57:54 -0500 Subject: [PATCH] accessing count directly in an output should is OK There should be no warning when accessing a resource's count value directly in an output. --- config/config.go | 2 +- config/test-fixtures/output-no-warnings/main.tf | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index c89f2ed7c3fd..2a62eb2b9544 100644 --- a/config/config.go +++ b/config/config.go @@ -849,7 +849,7 @@ func (c *Config) Validate() tfdiags.Diagnostics { // a count might dynamically be set to something // other than 1 and thus splat syntax is still needed // to be safe. - if r.RawCount != nil && r.RawCount.Raw != nil && r.RawCount.Raw["count"] != "1" { + if r.RawCount != nil && r.RawCount.Raw != nil && r.RawCount.Raw["count"] != "1" && rv.Field != "count" { diags = diags.Append(tfdiags.SimpleWarning(fmt.Sprintf( "output %q: must use splat syntax to access %s attribute %q, because it has \"count\" set; use %s.*.%s to obtain a list of the attributes across all instances", o.Name, diff --git a/config/test-fixtures/output-no-warnings/main.tf b/config/test-fixtures/output-no-warnings/main.tf index cd11419a86d0..6bf8cbbbce2c 100644 --- a/config/test-fixtures/output-no-warnings/main.tf +++ b/config/test-fixtures/output-no-warnings/main.tf @@ -4,3 +4,11 @@ resource "test_instance" "foo" { output "foo_id" { value = "${test_instance.foo.id}" } + +resource "test_instance" "bar" { + count = 3 +} + +output "bar_count" { + value = "${test_instance.bar.count}" +}