0

I'm using a heredoc to allow for multiple lines in a Terraform local-exec provisioner. For some reason when I use > to create a new file I'm getting a Protocal error.

I've tried wrapping it with single/double qoutes, but that did not work. However it does work as a single line command. command = "> foo"

How can I use > in a Terraform heredoc?

System Info:

[vagrant@rhel7 terraform-main]$ terraform --version
Terraform v0.12.7
+ provider.aws v2.27.0

HCL:

  provisioner "local-exec" {
    command = <<EOT
      > foo
    EOT
  }

Output:

Error: Error running command '      > foo
: Protocol error. Output: /bin/sh: foo

It looks like foo is being treated as a command...

I notice that touch has similar results.

command = <<EOT
  touch foo
EOT

Output:

Error: Error running command '      touch foo
': exit status 1. Output: touch: cannot touch ‘foo\r’: Protocol error
navig8tr
  • 1,724
  • 8
  • 31
  • 69

0 Answers0