Using templates to populate configuration resources with variables
Here is an example of HCL’s herefile or heredoc syntax, indicated by the arbitrary EOF
delimiters. It may be powerful to embed complex files into one HCL file, but it can also be very hard to read later down the road. This herefile syntax is most valuable when using variables as a template. For example, here we write a multiple-line herefile to our /etc/motd
file using the content
option, and we include the built-in ${build.PackerRunUUID}
variable so that each time someone logs in, they will be prompted with the unique build ID generated by Packer. You could also include one of your own variables or locals. Note the indentation of this syntax. The lines of a herefile in HCL are literal raw input from the beginning of each line, so if you indent your lines of text, the leading white space will be transferred to your file. This can make herefiles difficult to read in your template:
content ...