List items should be accessed using square brackets
This is a note about the following error that is produced by tflint
Warning: List items should be accessed using square brackets (terraform_deprecated_index)
on ec2.tf line 182:
182: target_id = aws_instance.ec2.*.id[count.index]
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.2.2/docs/rules/terraform_deprecated_index.md
I decided to make this not becuase the explanation at github.com/terraform-linters is not very clear.
The fix is the to replace all occurances of aws_instance.ec2.*.id[count.index]
with aws_instance.ec2.[count.index].id
Another optio is to switch to for loop. Here is an example in optputs:
output "ec2_private_ips" {
value = [for instances in aws_instance.ec2 : instances.private_ip]
}