Retrieving subnet cidr from multiple vpcs

We have multiple VPC’s that connect to another shared VPC via peering.
E.g. our Dev and QA VPCs share the DB VPC
We need to create a security group rule where we specify the cidr_blocks of the private subnets for each VPC(dev, qa).
We could use data sources to retrieve this information but would be repeating this for each VPC e.g.

data aws_vpc dev {
filter {
name = “name”
values = [“dev”]
}
}

data aws_subnet_ids dev {
vpc_id = aws_vpc.dev.vpc_id

tags = {
Tier = “private”
}
}

data aws_subnet dev {
for_each = data.aws_subnet_ids.dev.ids
id = each.value
}

Is there a better way to do this?