I am trying to use a multiline string in the provisioner "remote-exec"
block of my terraform script. Yet whenever I use the EOT
syntax as outlined in the documentation and various examples I get an error that complains about having: invalid characters in heredoc anchor
.
Here is an example of a simple provisioner "remote-exec"
that received this error (both types of EOT receive this error when attempted separately):
provisioner "remote-exec" {
inline = [
<< EOT
echo hi
EOT,
<< EOT
echo \
hi
EOT,
]
}
Update: Here is the working solution, read carefully if you are having this issue 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 you use in a provisioner "remote-exec"
block must be inside the EOF. You cannot have both EOF and non EOF its one or the other.
The first line of EOF must begin like this, and you cannot have any whitespace in this line after <<EOF
or else it will complain about having invalid characters in heredoc anchor
:
inline = [<<EOF
Your EOF must then end like this with the EOF
at the same indentation as the ]
EOF
]