It's for the public key variable for testing lab enviroments in my variables.tf file I tried

<<EOF the string EOF

but terraform dosn't seem to like that

  • why do you need the EOF? Can't you just add the string with linebreaks in it? Nov 11 '19 at 10:37
  • I can for this example I was haveing issues with the key pair to do with the formating iv now resolved and thought in future it would be more efficent to use multi line to change the key more easily.
    – doug
    Nov 11 '19 at 11:24
  • Ok. I' going to add the answer as appropriate Nov 11 '19 at 11:25
  • I have also seen examples where you have to do: <<-EOF LINE DATA EOF note the "<<-EOF" instead of "<<EOF"
    – atom88
    May 11 '20 at 15:17
  • I have also seen examples that use this, but I'm not sure why? <<EOT string data EOT discuss.hashicorp.com/t/line-continuation-within-a-variable/…
    – atom88
    May 11 '20 at 15:18

Terraform variable type constraints separate "primitive" types from "complex" types. These primitive types include strings:

A primitive type is a simple type that isn't made from any other types. All primitive types in Terraform are represented by a type keyword. The available primitive types are:

  • string: a sequence of Unicode characters representing some text, such as "hello".
  • number: a numeric value. The number type can represent both whole numbers like 15 and fractional values such as 6.283185.
  • bool: either true or false. bool values can be used in conditional logic.

So, simply declaring the variable as a string, with the linebreaks in it would suffice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.