terraform
terraform copied to clipboard
terraform destroy throws no such file or directory for data.local_file with relative path
Terraform Version
Terraform v1.3.2
on linux_amd64
Terraform Configuration Files
data "local_file" "front_door_profile_name" {
filename = "${path.module}/${var.config_dir}/../../.static/local_file.glob.front_door_name"
}
Debug Output
N/A
Expected Behavior
Terraform apply or plan could read that file, while destroy got error.
Actual Behavior
╷ │ Error: open ../config/lubimywarzywka.pl/../../.static/local_file.glob.front_door_name: no such file or directory │ │ with data.local_file.front_door_profile_name, │ on main.tf line 10, in data "local_file" "front_door_profile_name": │ 10: data "local_file" "front_door_profile_name" { │
Steps to Reproduce
terraform destroy
Additional Context
As workaround have used where var.static_dir
is "${var.config_dir}/.static"
data "local_file" "front_door_profile_name" {
filename = "${path.module}/${var.static_dir}/local_file.glob.front_door_name"
}
References
No response
Hi @jon-grey,
Thanks for filing the issue. I think we're going to need some more context in order to determine what is going on here. To start, is this run locally, or are you attempting to run this in TFC?
Terraform destroy
operates essentially the same as a normal plan an apply, so the fact that the file is not found at the given path is curious, as is the change to the path being a workaround. Do you have any other resources in the configuration which attempt to modify that file, which remove it during destroy
? The path segment ../../
looks like the file is not stored as part of the given module, are you sure the file exists at that location when running terraform destroy
in the first place?
Thanks!
Since we have not heard back in a while I'm going to close the issue. If you have any updates regarding the issue, feel free to open a new issue with the requested information. If you have more questions, you can also use the community forum where there are more people ready to help.
Thanks!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.