Hi
We seem to be hitting an issue with an erb templated tfvars file that we didn’t have previously in 2.1.7.
We now get the following output from a plan:
NameError: undefined local variable or method `customer_name' for
#<Terraspace::Compiler::Erb::Context:0x000055fd14cf91c8>
Did you mean? customer_settings
Error evaluating ERB template around line 11 of: /tmp/terraspace/rewrite/app/stacks/0001b-pre_reqs/tfvars/base.tfvars:
6 ############################
7 # Loop - for each environment block
8 ############################
9 <%# customer_data['environments']&.each do |environment_name, environment_data| %>
10
11 account_id_<%= customer_name %>_<%= environment_name %> = <%= output("0001a-account_factory.account_id_#{customer_name}_#{environment_name}") %>
12
13 ############################
14 # End Loop - for each environment block #
15 ############################
16 <%# end %>
Compared to a working plan in 2.1.7
The code for the base.tfvars that it is trying to render is:
############################
\# Loop - for each customer block
############################
<% deployment_settings['accounts']&.each do |customer_name, customer_data| %>
############################
\# Loop - for each environment block
############################
<% customer_data['environments']&.each do |environment_name, environment_data| %>
account_id_<%= customer_name %>_<%= environment_name %> = <%= output("0001a-account_factory.account_id_#{customer_name}_#{environment_name}") %>
############################
\# End Loop - for each environment block
############################
<% end %>
############################
\# End Loop - for each customer block
############################
<% end %>
As you can see, the variable customer_name
clearly comes from the
<% deployment_settings['accounts']&.each do |customer_name, customer_data| %>
line but in the trace, the erb “each” statements are remarked.
Regards
Martyn