terragrunt
terragrunt copied to clipboard
Terragrunt converts absolute paths into relative paths that breaks functionality
Describe the bug
Terragrunt converts absolute file paths into relative paths that breaks functionality.
Steps To Reproduce
# main.tf
variable "myabsolutepath"{
type = string
}
output "varOut"{
value = var.myabsolutepath
}
#terragrunt.hcl
inputs = {
myabsolutepath = "/workspace/modules"
}
Running terragrunt plan results in:
.
.
.
10:04:07.731 STDOUT terraform: Changes to Outputs:
10:04:07.731 STDOUT terraform: + varOut = "./modules" <== !! Converted to relative path
10:04:07.732 STDOUT terraform: You can apply this plan to save these new output values to the Terraform
10:04:07.732 STDOUT terraform: state, without changing any real infrastructure.
.
.
.
Running terraform plan results in:
Changes to Outputs:
+ varOut = "/workspace/modules" <== !! Renders correctly
You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
.
.
.
Note: In the above terragrunt.hcl if I remove the leading '/', it does not convert the string (and renders it as 'workspace/modules').
Expected behavior
I expect the absolute path preserved
Versions
terragrunt version v0.78.4 Terraform v1.12.0 Ubuntu 22.04.5 LTS
Additional context
This relative path breaks some local-exec provisioners inside the terraform as the meaning of the relative paths change at the time of terraform execution (as the current directory is different at the run time).
Please let me know if you need more information in this regard.
Thanks
Maybe what you see in the logs is not the reality. Take a look in the statefile how the path is stored
try terragrunt run apply --all --log-show-abs-paths
this my also help https://github.com/gruntwork-io/terragrunt/issues/4255#issuecomment-2880948409 but that did not help for me. I was already using a absolute path. It was just converted to a relative path in the logs
hey @SrinivasanSundaram-HO
I was unable to reproduce your issue with the provided fixture.
# main.tf
variable "myabsolutepath"{
type = string
}
output "varOut"{
value = var.myabsolutepath
}
#terragrunt.hcl
inputs = {
myabsolutepath = "/workspace/modules"
}
output from terragrunt plan
STDOUT terraform: + varOut = "/workspace/modules"
Can you check if there are any extra files that could hold variables or ENV vars in your shell?
i have the same problem. it looks like it is a terragrunt output problem (but i am not 100% sure). also the behavior is not consistent with different paths. my findings:
- paths in nested objects or simple string variables can get replaced by relative path
../../../../../../../../../user/app/example.com/public - the path
/usr/local/binstays absolut /etc/aptstays absolut- changing in the cache dir and running tofu directly leaves the path alone (data provided with
test.auto.vars - the data in the state file and the data stored with the provider is correct (absulute path). also with terragrunt
so i assume it is an output bug for paths the terragrunt files is located. being in a path
/home/user/my-terragunt-projectand running terragunt there while providing an absolut path starting with/homemakes the path relative in the output. providing a different stating point like/varas variable content, leads to the correct output. but always the correct data is stored.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for raising this issue.