Loading...
Loading...
`Terraform init` fails to initialize provider plugin binaries when run from a symlinked directory targeting a path upwards in the hierarchy. ### Terraform Version This issue is present on all versions of tf I am aware of. I am currently running the master branch: ``` $ ./terraform -v Terraform v0.13.0-dev ``` ### Terraform Configuration Files This is the complete configuration: just trying to initialize a provider (in this case AWS): ```hcl provider "aws" { profile = "default" region = "us-east-1" } ``` ### Debug Output This debug output is not very long, so I am pasting here: ``` $ TF_LOG=trace terraform init -plugin-dir=/tmp/tf-config-dir/plugins /tmp/tf-config-dir/ 2020/02/24 09:09:26 [INFO] Terraform version: 0.12.8 2020/02/24 09:09:26 [INFO] Go runtime version: go1.12.9 2020/02/24 09:09:26 [INFO] CLI args: []string{"/home/padillon/bin/terraform", "init", "-plugin-dir=/tmp/tf-config-dir/plugins", "/tmp/tf-config-dir/"} 2020/02/24 09:09:26 [DEBUG] Attempting to open CLI config file: /home/padillon/.terraformrc 2020/02/24 09:09:26 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. 2020/02/24 09:09:26 [DEBUG] checking for credentials in "/home/padillon/.terraform.d/plugins" 2020/02/24 09:09:26 [INFO] CLI command args: []string{"init", "-plugin-dir=/tmp/tf-config-dir/plugins", "/tmp/tf-config-dir/"} There are some problems with the configuration, described below. The Terraform configuration must be valid before initialization so that Terraform can determine which modules and providers need to be installed. Error: Failed to read module directory Module directory ../../../../../tmp/tf-config-dir does not exist or cannot be read. ``` ### Expected Behavior `terraform init` should complete successfully in a symlinked directory just as it would in the symlink target. ### Actual Behavior `terraform init` completes successfully in the target, but crashes with the error listed in Debug Output when run from the symlinked dir. ### Steps to Reproduce 1. Create a target directory higher in the hierarchy, e.g.: ``` $ tree /tmp/tf-config-dir/ /tmp/tf-config-dir/ ├── example.tf └── plugins └── terraform-provider-aws ``` 2. Run terraform from a symlink directory: ``` $ ls -al drwxrwxr-x. 4 padillon padillon 4096 Feb 21 16:37 a lrwxrwxrwx. 1 padillon padillon 6 Feb 21 16:25 symlink-dir -> a/b/c/ [symlink-dir]$ terraform init -plugin-dir=/tmp/tf-config-dir/plugins /tmp/tf-config-dir/ ``` ### Additional Context Note that when run from the symlink target it initializes: ``` [c]$ terraform init -plugin-dir=/tmp/tf-config-dir/plugins /tmp/tf-config-dir/ Initializing the backend... Initializing provider plugins... Terraform has been successfully initialized! ``` ### References Will post a PR shortly after this.
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.