Perform arithmetic operation in tpl file

Hi,
I have one tpl file where I am trying to perform some arithmetic operation. But unfortunately, the terraform simply copies that value in generated file instead of performing mathematical operation. Can somebody suggest how to achieve that ?
Example:
%{ for key in env_name ~}
key=${key}+1
%{ endfor }
Original output :
key=0-1
key=1-1
key=2-1
Expected output :
key = -1
key = 0
key = 1

You wrote the arithmetic expression outside of the ${ } delimiters so of course it was processed as plain text. The documentation of the template syntax can be found at Strings and Templates - Configuration Language | Terraform | HashiCorp Developer

Everything outside of ${ } or %{ } is copied to the output as is.

I tried to put the whole expression inside ${} that also didn’t work. It gives error : Invalid character; This character is not used within the language., and 1 other diagnostic(s).

See: Guide to asking for help in this forum