Hello,
I am trying the create the following Makefile locally on a server created through terraform,
template user_data.sh.tpl
creates a user_data shell script created at the start of the server.
One of the things this script does is to create a Makefile :
[...]
cat << EOF > /opt/Makefile
### DB helpers
echo_db_dump:
jq '.db' config.json
date '+%Y-%m-%d_%H-%M-%S%z_%Z'
echo "pg_dump $$$(jq '.db' config.json) > db-$$$(shell date '+%Y-%m-%d_%H-%M-%S%z_%Z').sql -Fc"
echo "tar cvzf <>.tgz <previousfile.sql>
EOF
data "template_file" "userdata" {
template = "${file("${path.module}/files/user_data.sh.tpl")}"
}
[...]
user_data = data.template_file.userdata.rendered
[...]
template resulting Makefile…
echo_db_dump:
jq '.db' config.json
date '+%Y-%m-%d_%H-%M-%S%z_%Z'
echo "pg_dump 1050 > db-1050.sql -Fc"
echo "tar cvzf <>.tgz <previousfile.sql>
so my question is how should I escape the Makefile
$$()
so that they are actually printed by the shell script, and not interpreted anytime before ?
Thanks in advance to anyone with some clues…