Data aws_volumes with a for_each

I would like to get a list of IDS based on data.aws_instances that then I can us in aws_ebs volume
I tried
data “aws_ebs_volumes” “volumes”
for_each = toset(data.aws_instances.instances.ids)
ids = each.value.ids
but got Computed attributes cannot be set, but a value was set for “ids”