Hi,
In the Terraform documentation I found a data source called aws_ebs_volumes and in the example they use aws_ebs_volume data source too (code below)
`data "aws_ebs_volumes" "example" {
tags = {
VolumeSet = "TestVolumeSet"
}
}
data "aws_ebs_volume" "example" {
for_each = data.aws_ebs_volumes.example.ids
filter {
name = "volume-id"
values = [each.value]
}
}`
The question is, can I do the same with aws_instances and aws_instance ? I have the following code
`#return all the instances that fill the paramenters (filters)
data "aws_instances" "get_instances" {
filter {
name = "instance-type"
values = ["t2.micro"]
}
filter {
name = "availability-zone"
values = ["sa-east-1a"]
}
instance_state_names = ["running", "stopped"]
}
#return the data of one specific insntace
data "aws_instance" "get_specific_instance" {
for_each = "${data.aws_instances.get_instances.ids}"
filter {
name = "tag:Name"
values = ["PocTerraform", "Application"]
}
}`
but it doesn’t work, is it just syntax errors or it’s not possible to do it?
Thanks in advance