Bash variables with curly braces ${} in template files

2,953 views
Skip to first unread message

Igor Cicimov

unread,
Dec 14, 2015, 1:43:41 AM12/14/15
to Terraform
Hi,

Is there a way to tell TF that:

${var1:$((${#var1}-1)):1}

is bash variable in a shell script that's being rendered as template? Or is there any way of escaping this kind of vars so TF does not think they are var placeholders?

Thanks,
Igor

Michael Daffin

unread,
Dec 14, 2015, 3:22:00 AM12/14/15
to Terraform

Use double dollar, $$, to escape interpolation.


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/49aa38c5-b51a-44f6-a64e-6b96fe970e57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Igor Cicimov

unread,
Dec 14, 2015, 7:15:20 PM12/14/15
to Terraform
_doh_, no idea how did I missed that or forgot about, it's in the very first paragraph of the interpolation document page ... Thanks, Michael.

Ozair Tukhi

unread,
May 29, 2018, 9:39:06 PM5/29/18
to Terraform
I have the same issue. But when I use $$, terraform plan accepts it but terraform apply does not. Also the $$var in bash passes the name of the variable preceded by number 2. I am really stuck and don't know what to do. I'd really appreciate any help.

Ozair Tukhi

unread,
May 29, 2018, 9:40:16 PM5/29/18
to Terraform

Ozair Tukhi

unread,
May 29, 2018, 9:40:29 PM5/29/18
to Terraform


On Monday, December 14, 2015 at 3:22:00 AM UTC-5, Michael Daffin wrote:

Ozair Tukhi

unread,
May 29, 2018, 9:41:03 PM5/29/18
to Terraform

I have the same issue. But when I use $$, terraform plan accepts it but terraform apply does not. Also the $$var in bash passes the name of the variable preceded by number 2. I am really stuck and don't know what to do. I'd really appreciate any help

On Monday, December 14, 2015 at 3:22:00 AM UTC-5, Michael Daffin wrote:
Reply all
Reply to author
Forward
0 new messages