Terraform: 0.12 - init fails with multiple uses of a module and module's repo contains symlink

Created on 1 Mar 2019  ยท  4Comments  ยท  Source: hashicorp/terraform

Terraform Version

Terraform v0.12.0-beta1

Terraform Configuration Files

module "test" {
  source = "git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro//module"
}
module "test2" {
  source = "git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro//module"
}

Debug Output

2019/03/01 09:30:19 [INFO] Terraform version: 0.12.0 beta1
2019/03/01 09:30:19 [INFO] Go runtime version: go1.11.5
2019/03/01 09:30:19 [INFO] CLI args: []string{"/Users/peterr/Downloads/terraform", "init"}
2019/03/01 09:30:19 [DEBUG] Attempting to open CLI config file: /Users/peterr/.terraformrc
2019/03/01 09:30:19 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/03/01 09:30:19 [INFO] CLI command args: []string{"init"}
Initializing modules...
2019/03/01 09:30:19 [TRACE] ModuleInstaller: installing child modules for . into .terraform/modules
2019/03/01 09:30:19 [DEBUG] Module installer: begin test
2019/03/01 09:30:19 [TRACE] ModuleInstaller: test is not yet installed
2019/03/01 09:30:19 [TRACE] ModuleInstaller: cleaning directory .terraform/modules/test prior to install of test
2019/03/01 09:30:19 [TRACE] ModuleInstaller: test address "git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro//module" will be handled by go-getter
2019/03/01 09:30:19 [DEBUG] will download "git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro" to .terraform/modules/test
2019/03/01 09:30:19 [TRACE] fetching "git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro" to ".terraform/modules/test"
Downloading git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro for test...
2019/03/01 09:30:20 [TRACE] expanded "module" to ".terraform/modules/test/module"
2019/03/01 09:30:20 [TRACE] ModuleInstaller: test "git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro//module" was downloaded to .terraform/modules/test/module
2019/03/01 09:30:20 [DEBUG] Module installer: test installed at .terraform/modules/test/module
2019/03/01 09:30:20 [DEBUG] Module installer: begin test2
2019/03/01 09:30:20 [TRACE] ModuleInstaller: test2 is not yet installed
2019/03/01 09:30:20 [TRACE] ModuleInstaller: cleaning directory .terraform/modules/test2 prior to install of test2
- test in .terraform/modules/test/module
2019/03/01 09:30:20 [TRACE] ModuleInstaller: test2 address "git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro//module" will be handled by go-getter
2019/03/01 09:30:20 [DEBUG] will download "git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro" to .terraform/modules/test2
2019/03/01 09:30:20 [TRACE] copying previous install .terraform/modules/test to .terraform/modules/test2
Downloading git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro for test2...
2019/03/01 09:30:20 [TRACE] modsdir: writing modules manifest to .terraform/modules/modules.json

Error: Failed to download module

Error attempting to download module "test2" (main.tf:4) source code from
"git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro":
failed to copy from .terraform/modules/test to .terraform/modules/test2: read
.terraform/modules/test/symlink: is a directory


Error: Failed to download module

Error attempting to download module "test2" (main.tf:4) source code from
"git::ssh://[email protected]/rifelpet/terraform-module-symlink-repro":
failed to copy from .terraform/modules/test to .terraform/modules/test2: read
.terraform/modules/test/symlink: is a directory

Expected Behavior

terraform init completes successfully

Actual Behavior

terraform init fails with a copy error

Steps to Reproduce

This repo contains a terraform module as well as an unrelated symlink.

When invoking the module module in that repo multiple times, terraform 0.12 will download the repo once and then copy it locally as many times as needed, to avoid redundant downloading. If the git repo contains a symlink (even if its not in the module's subdirectory), the copy will fail. Removing the symlink from the repo causes init to succeed. I'm not aware of how well terraform supports following symlinks, but in this case its not even used by terraform, it just happens to also be in the repo. It would be great if terraform's module downloading could successfully copy git repos containing symlinks.

Additional Context

The error is logged here and I'm guessing that the copyDir function isnt looking for symlinks within the directory it is copying, causing this open to fail.

References

N/A

bug cli

Most helpful comment

@rifelpet - I also want to thank you for providing an example repository!

All 4 comments

Thanks for reporting this, @rifelpet!

We'll fix this up to support symlinks properly.

@rifelpet - I also want to thank you for providing an example repository!

@rifelpet will this be fixed in 0.11 too? I have 0.11.14 and I just went into identical problem :(

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.

Was this page helpful?
0 / 5 - 0 ratings