HiveBrain v1.2.0
Get Started
← Back to all entries
snippetterraformMinor

How do I enter a multi line variable in Terraform?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
multilineenterhowvariableterraform

Problem

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

Solution

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.

Context

StackExchange DevOps Q#9752, answer score: 2

Revisions (0)

No revisions yet.