I am trying to print , private ip of the newly created instances into a host file locally where i run terraform from, to use it for ansible,but terraform is throwing errors, each time I modify my escape characters in the local-exec echo command.
here is the snippet where i am getting error:
provisioner "local-exec"
{
command = " echo \"[servers]\["${aws_instance.seeds.*.private_ip}"\]\" >> /ec2-ansible/hosts"
}
expected output in the hosts file:
[servers]
ip1
ip2
ip3
errors I am getting:
Failed to load root config module: Error parsing /root/ec2-ansible/main.tf: At 33:1: expected: IDENT | STRING | ASSIGN | LBRACE got: RBRACE
Failed to load root config module: Error parsing /root/ec2-ansible/main.tf: At 29:25: illegal char
Can anyone help me with this ?