I have a script that runs through all the files in my local directory and finds key words in my terraform files. The issue I'm facing is that I'm unable to replace defined variables in the files. When I reference value to be replaced, it captures $variable as the reference instead. For example:
Repository_Name="test"
grep -rl '#{RepositoryName}#' --include *.tf |
xargs gsed -i 's/#{RepositoryName}#/${Repository_Name}/g'
I've also tried removing the {} outside the variable like the example below and still no luck:
Repository_Name="test"
grep -rl '#{RepositoryName}#' --include *.tf |
xargs gsed -i 's/#{RepositoryName}#/$Repository_Name/g'
The result I usually get is:
RepositoryName = "$Repository_Name"
or
RepositoryName = "${Repository_Name}"