Hey @venu1428,
As you’ve stated it is not possible to use interpolated values in the Terraform block itself.
If you are looking for a solution to generate a main.tf
pre-runtime of terraform
then two of the options you mentioned should be able to do that.
- terragrunt
- custom file generator script (this could be Python, just a is aware of HCL syntax and templatizes that in a way)
It depends on your use case. If you only planning on creating these files with generated Terraform blocks in bulk once or twice, I would personally write a bash or Python script to achieve this.
Otherwise, I would configure it to be compatible with Terragrunt as it seems to do precisely what you are looking for. A tutorial covering dynamically creating an S3 remote backend using variables can be found on Gruntwork’s Medium blog.
Additionally, the official terragrunt
README has a relevant snippet on to generate an remote backend block on S3.
@mpmsimo Thanks for the responce
I got error try to get the source from terragrunt.
terragrunt.hcl
terraform {
Deploy version v0.0.3 in stage
source = “git::git@github.com:xxxxxx/Terragrunt.git//dev/modules/App”
}
I got error like
nXyH3Nj2SAZrSzhLIfyHKLc8e8’…
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
====================================
" I would personally write a bash or Python script to achieve this."can you give a example for this one to refer.