I am building ec2 instances using passing count variable to pass number ec2 instances. Part of the code when i am trying add storage referencing the instance i am getting following error. How should we refer instance_id in volume attachment resource ?
resource "aws_ebs_volume" "Vol1" {
availability_zone = "us-east1a"
size = 10
encrypted = "true"
}
resource "aws_volume_attachment" "install" {
device_name ="/dev/sdf"
volume_id= aws_ebs_volume.Vol1.id
instance_id = "${aws_instance.tf_instance.*.id[count.index]}"
}
The “count” object can be used only in “resource” and “data” blocks, and only
when the “count” argument is set.
Can some one please help.