ERB interpolation with TF values

Hello there, was wondering if there is a way to interpolate TF values (variables, locals, etc…) in ERB expressions. Looked high and low could not find anything in docs, tried different permutations but no luck.

As per you examples

user = "<%= azure_secret("demo-#{Terraspace.env}-user") %>"
pass = "<%= azure_secret("demo-#{Terraspace.env}-pass") %>"

Above we are interpolation Terraspace values can we use TF values instead, something like below

user = "<%= azure_secret("demo-#{each.value.user}-user") %>"
pass = "<%= azure_secret("demo-#{each.value.pass}-pass") %>"

A few things I tried

user = "<%= azure_secret("demo-${each.value.user}-user") %>"
pass = "<%= azure_secret("demo-${each.value.pass}-pass") %>"
user = "<%= azure_secret("demo-#{@each.value.user}-user") %>"
pass = "<%= azure_secret("demo-#{@each.value.pass}-pass") %>"

Not possible. The ERB evaluation is a “preprocessor”.

The terraform apply later runs after the preprocessor has completed.

So the contexts are completely different. Hope that at least answers the question. :+1:

It does, thank you for the reply.
BTW great job on the tool, enjoying it so far!

1 Like