Using the expansion operator with resource splat expression

Is it possible to use the expansion operator when referring to a resource using the splat expression (implying that 0 or more are created)? My initial attempts were unsuccessful at getting this to work.

It would seem possible since References to Named Values mentions the type is a list:

If the resource has the count argument set, the value of this expression is a list of objects representing its instances.

Initial use-case:

variable create {
    type = bool

resource aws_s3_bucket bucket {
  count = var.create ? 1 : 0

I would expect to be able to use the expansion operator with this, but it doesn’t seem to work. This is a contrived example, but valid:

output bucket_ids {
  value = list(aws_s3_bucket.bucket[*].id...)

provides the error:

Error: Invalid expanding argument value

  on ./ line 6, in output "bucket_ids":
   6:   value = list(aws_s3_bucket.bucket[*].id...)

The expanding argument (indicated by ...) must be of a tuple, list, or set

While there may be better approaches to this case, I think the use of expansion with splat expressions is valid.

Hi @phillipjf,

I think you’ve run into this bug:

The good news is that someone else on the Terraform team has already been working on a fix for it, so it should hopefully be resolved soon.

Yes, it seems so! I was able to test this in the console using a resource with the count attribute and verify that it does work there. My Google-fu failed me since I was specifically looking for accessing resources with splat operators. Thank you!