I am trying to use a multi-line string in the provisioner "remote-exec" block of my terraform script. However, whenever I use the EOT syntax, as described in the documentation and various examples, I get an error message: invalid characters in heredoc anchor .
Here is an example of a simple provisioner "remote-exec" that received this error (both types of EOT get this error when trying separately):
provisioner "remote-exec" { inline = [ << EOT echo hi EOT, << EOT echo \ hi EOT, ] }
Update: Here is a working solution, read carefully if you have this problem, because terraform is very picky when it comes to EOF:
provisioner "remote-exec" { inline = [<<EOF echo foo echo bar EOF ] }
Note that if you want to use EOF, all the commands that you use in the provisioner "remote-exec" block must be inside EOF. You cannot have either EOF or non-EOF one or the other.
The first line of EOF should start the same way, and you cannot have spaces in this line after <<EOF , otherwise it will complain about the presence of invalid characters in heredoc anchor :
inline = [<<EOF
Then your EOF should end like this: EOF in the same indent as ]
EOF ]
source share