1
votes

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")??

1

1 Answers

3
votes

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.