edmamerto
edmamerto

Reputation: 8165

Terraform escaping bash command substitution

When working with inline bash in terraform, I know that I have to escape interpolation with $${foo} and will be rendered as literal ${foo}

What about for bash command substitions?

do i need to $$(echo "hello") <= $(echo "hello")??

Upvotes: 1

Views: 1085

Answers (1)

Josh Padnick
Josh Padnick

Reputation: 3278

No, you do not need to use $$(echo "hello"). $(echo "hello") is fine.

Terraform will always interpret ${...} (with curly braces) as an indicator that it should interpolate the text between the curly braces. But sometimes you actually want the string literal ${...}, in which case you need a way to escape that sequence, which as you pointed out can be done like this: $${...}.

But $ by itself is seen as a literal by Terraform, so you can just include it without escaping it.

Upvotes: 3

Related Questions