Loading...
Loading...
### Terraform Version ```shell Terraform v1.3.3 on linux_amd64 ``` ### Terraform Configuration Files ```terraform terraform { required_version = "~> 1.0" backend "s3" { # to be provided externally } required_providers { aws = { source = "hashicorp/aws" version = "~> 4.2.0" } } } ``` ### Debug Output ``` skolesnik@Stepan-XPS:~/Documents/workspace/spike/category-data/terraform$ TF_LOG=trace terraform init -input=false -back end-config="/mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars" 2022-10-24T19:51:06.331+0200 [INFO] Terraform version: 1.3.3 2022-10-24T19:51:06.331+0200 [DEBUG] using github.com/hashicorp/go-tfe v1.9.0 2022-10-24T19:51:06.331+0200 [DEBUG] using github.com/hashicorp/hcl/v2 v2.14.1 2022-10-24T19:51:06.331+0200 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 2022-10-24T19:51:06.331+0200 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 2022-10-24T19:51:06.331+0200 [DEBUG] using github.com/zclconf/go-cty v1.11.1 2022-10-24T19:51:06.331+0200 [INFO] Go runtime version: go1.19.1 2022-10-24T19:51:06.331+0200 [INFO] CLI args: []string{"terraform", "init", "-input=false", "-backend-config=/mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars"} 2022-10-24T19:51:06.331+0200 [TRACE] Stdout is a terminal of width 120 2022-10-24T19:51:06.331+0200 [TRACE] Stderr is a terminal of width 120 2022-10-24T19:51:06.331+0200 [TRACE] Stdin is a terminal 2022-10-24T19:51:06.331+0200 [DEBUG] Attempting to open CLI config file: /home/skolesnik/.terraformrc 2022-10-24T19:51:06.331+0200 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. 2022-10-24T19:51:06.331+0200 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins 2022-10-24T19:51:06.331+0200 [DEBUG] ignoring non-existing provider search directory /home/skolesnik/.terraform.d/plugins 2022-10-24T19:51:06.331+0200 [DEBUG] ignoring non-existing provider search directory /home/skolesnik/.local/share/terraform/plugins 2022-10-24T19:51:06.331+0200 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins 2022-10-24T19:51:06.331+0200 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins 2022-10-24T19:51:06.331+0200 [DEBUG] ignoring non-existing provider search directory /var/lib/snapd/desktop/terraform/plugins 2022-10-24T19:51:06.332+0200 [INFO] CLI command args: []string{"init", "-input=false", "-backend-config=/mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars"} Initializing the backend... ╷ │ Error: Failed to read file │ │ The file │ "../../../../../../../mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars" could │ not be read. ╵ ``` ### Expected Behavior The backend-config file should have been successfully loaded from the absolute path (without a transformation to a relative one) as the file itself is perfectly readable via the provided absolute path: ``` ls -la /mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvarsolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars -rwxrwxrwx 1 skolesnik skolesnik 120 Oct 24 19:38 /mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars ``` ### Actual Behavior The terraform failed to load the backend-config file. ``` Initializing the backend... ╷ │ Error: Failed to read file │ │ The file │ "../../../../../../../mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars" could │ not be read. ╵ ``` ### Steps to Reproduce ``` terraform init -input=false -backend-config="$TF_BACKEND_CONFIG_PATH" ``` There are indications that the issue could be caused by the WSL's strange handling of symlinks. See additional context for more information. ### Additional Context 1. Terraform is used from Ubuntu 20.04 LTS on top of WSL (Windows 11 PRO 22H2). 2. The parent directory of where the terraform files live is symlinked to the user profile on the main Windows drive as per below: ``` skolesnik@Stepan-XPS:~$ ls -l total 0 lrwxrwxrwx 1 skolesnik skolesnik 32 Oct 24 18:31 Documents -> /mnt/c/Users/skolesnik/Documents lrwxrwxrwx 1 skolesnik skolesnik 32 Oct 24 18:31 Downloads -> /mnt/c/Users/skolesnik/Downloads lrwxrwxrwx 1 skolesnik skolesnik 31 Oct 24 18:31 Pictures -> /mnt/c/Users/skolesnik/Pictures skolesnik@Stepan-XPS:~$ readlink -f ~/Documents/workspace/spike/category-data/target/tf_backend.tfvars /mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars ``` 3. Weirdly, the relative path which Terraform transforms the provided absolute path to seems to be correct, but it cannot be read by the file system either, see below: ``` skolesnik@Stepan-XPS:~/Documents/workspace/spike/category-data/terraform$ pwd /home/skolesnik/Documents/workspace/spike/category-data/terraform skolesnik@Stepan-XPS:~/Documents/workspace/spike/category-data/terraform$ terraform init -input=false -backend-config=/mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars Initializing the backend... ╷ │ Error: Failed to read file │ │ The file │ "../../../../../../../mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars" could │ not be read. ╵ skolesnik@Stepan-XPS:~/Documents/workspace/spike/category-data/terraform$ ls -la ../../../../../../../mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars ls: cannot access '../../../../../../../mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars': No such file or directory ``` 4. Even more weirdly, if the relative path is slightly amended by prepending two additional `../` then the file can be accessed: ``` skolesnik@Stepan-XPS:~/Documents/workspace/spike/category-data/terraform$ ls -la ../../../../../../../../../mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars -rwxrwxrwx 1 skolesnik skolesnik 120 Oct 24 2022 ../../../../../../../../../mnt/c/Users/skolesnik/Documents/workspace/spike/category-data/target/tf_backend.tfvars ``` 5. Regardless of all of the above, shouldn't Terraform just use the absolute path if it is explicitly provided by the user? 6. Naturally, working from a non-symlinked directory works fine ### References - #24196
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.