I am using terragrunt to create an environment using the approach of storing the remote state into my local path.
remote_state {
backend = "local"
config = {
path= "../..//mypath/terraform.tfstate"
}
}
but because terragrunt downloads the terraform modules in a temporary folder by default .terragrunt-cache, it does not set them in the original path but in the temporary path. I am using the following command in the path where my root file is located:
terragrunt run-all apply --terragrunt-download-dir C:\Tempfile Using --terragrunt-download-dir but this will only downloads the temporal folder in a specific path and i want to set my terraform.tfstate in the original path not the temporary folder.
You can specify where the terraform.state will be save by using TerraGrunt to write the backend.tf so that is also sets the path for the state file, like so:
backend.tf should look something like:
generate
block will generate a "backend.tf" file in the Terraform module that it downloads into the.terragrunt-cache
directory.Note this means that you would need to remove
backend
config from any other *.tf files.Also, if you have terragrunt.hcl files that are only meant to be included in other terragrunt.hcl modules or do not produce any infrastructure, then you'll want to make use of TerraGrunt's skip attribute so the
run-all apply
command does not try to process them.Tested with
terragrunt version v0.42.5
andTerraform v1.3.6
on Windows.