External command newline seen as question mark in linux

data "external" "check_consul_bootstrap" {
        program = ["ssh", "-o", "StrictHostKeyChecking=no", "root@${var.consul_servers.omni-consul-0["ip_address"]}", <<EOF
        export CONSUL_CAPATH=/etc/consul.d/certs/ca.crt
        export CONSUL_CLIENT_CERT=/etc/consul.d/certs/host.crt
        export CONSUL_HTTP_SSL_VERIFY=true
        while true; do if consul members &> /dev/null; then break; fi; sleep 2; done
        token="dummy"
        jq -n --arg token "$token" '{"token":$token}'
        EOF
        ]
        depends_on = [
                # time_sleep.wait_15_seconds_consul,
                vsphere_virtual_machine.consul_server,
        ]

}

I’m running this command on a virtual machine, which on the VM is translated into:

root        2158    2104  0  1940  3396   0 17:20 ?        00:00:00 bash -c ?export CONSUL_CAPATH=/etc/consul.d/certs/ca.crt ?export CONSUL_CLIENT_CERT=/etc/consul.d/certs/host.crt
?export CONSUL_HTTP_SSL_VERIFY=true ?while true; do if consul members &> /dev/null; then break; fi; sleep 2; done ?token="dummy" ?jq -n --arg token "$token" '{"token":$token}'

for some weird reason. before each line in the terraform config file there are also tabs. Any ideas why this is happening?

Changing the tabs to spaces and adding ; after each command returns this:

bash -c         export CONSUL_CAPATH=/etc/consul.d/certs/ca.crt;         export CONSUL_CLIENT_CERT=/etc/consul.d/certs/host.crt;         export CONSUL_HTTP_SSL_VERIFY=true;         while true; do if consul members &> /dev/null; then break; fi; sleep 2; done;         token="dummy";         jq -n --arg token "$token" '{"token":$token}';

Which still isn’t working.

Never mind. It does look weird, but it works nonetheless. I forgot to add the consul client certificate key in the environmental variables. It showed up much later in the terraform output for some reason, but redirecting the error to a file on the VM might have worked too.

You included newline characters inside a command line argument and the means you are using to view the command line is choosing to render them as question marks.

Yeah, it’s just ps aux or ps -eF with less/more :slight_smile: