Merge pull request #16866 from hashicorp/jbardin/count-splat-warning

accessing count directly in an output should is OK
This commit is contained in:
James Bardin 2017-12-07 09:40:47 -05:00 committed by GitHub
commit 62eb5ba726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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,

View File

@ -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}"
}