Data "aws_subnet" returning error that attributes cannot be determined

Hello all, I have been trying to add my opensearch module to our root module in terraform cloud but the data lookups in the module seems to be causing an issue. If I run Terraform locally on my computer this will work fine. I can even just create a local module with data/outputs and these lines work fine as well. They just do not want to work in terraform cloud for some reason that I am not aware of or can’t track down. Even stranger is that I have these lines in a different module referenced in my root module that are essentially identical that work fine there. Can anyone point me in the right direction? We are using most recent version of terraform in terraform cloud.

data “aws_vpcs” “vpcs” {
tags = {
Name = “shared-${var.eb_env}”
}
}

data “aws_subnet_ids” “private_subnets” {
vpc_id = element(tolist(data.aws_vpcs.vpcs.ids), 0)
tags = {
Name = “private
}
}

data “aws_subnet” “private” {
for_each = data.aws_subnet_ids.private_subnets.ids
id = each.value
}

Here is the error I receive in Terraform cloud. Line 54 is where these data lookups start in the data.tf file.

Error: Invalid for_each argument

on .terraform/modules/opensearch/data.tf line 54, in data “aws_subnet” “private”:

  for_each = data.aws_subnet_ids.private_subnets.ids

The “for_each” value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the for_each depends on.