Merge pull request #16866 from hashicorp/jbardin/count-splat-warning
accessing count directly in an output should is OK
This commit is contained in:
commit
62eb5ba726
|
@ -849,7 +849,7 @@ func (c *Config) Validate() tfdiags.Diagnostics {
|
||||||
// a count might dynamically be set to something
|
// a count might dynamically be set to something
|
||||||
// other than 1 and thus splat syntax is still needed
|
// other than 1 and thus splat syntax is still needed
|
||||||
// to be safe.
|
// 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(
|
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",
|
"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,
|
o.Name,
|
||||||
|
|
|
@ -4,3 +4,11 @@ resource "test_instance" "foo" {
|
||||||
output "foo_id" {
|
output "foo_id" {
|
||||||
value = "${test_instance.foo.id}"
|
value = "${test_instance.foo.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "test_instance" "bar" {
|
||||||
|
count = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
output "bar_count" {
|
||||||
|
value = "${test_instance.bar.count}"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue