Terraform, conditionally execute some lines of code in template file

Viewed 1230

In terraform, is there any way to conditionally execute some lines of code in template file? For example:

I have a test.sh.tpl file defined as below called from main.tf

#!/bin/bash echo ${test_key} > /opt/test_key.properties

In the above value to "test_key" is assigned from variable

Now I want to execute the above code only if ${test_key} value is not empty. I tried this, but not working even the value exists

{ if ${test_key} != "" }

echo ${test_key} > /opt/test_key.properties

{ endif }

1 Answers
Related