Terraform working directory not set to ConfigDirectory
when in use
#277
Labels
bug
Something isn't working
ConfigDirectory
when in use
#277
terraform-plugin-testing version
The following code was from the
local
provider when attempting to refactor some of the tests to useConfigDirectory
: https://github.com/hashicorp/terraform-provider-local/blob/3b59b2e8a560c88b572fb46d3965bc9ae3a52ff3/internal/provider/data_source_local_file_test.goProblem
Implementing a test utilizing
(TestStep).ConfigDirectory
with the following directory structure:$ tree . ├── data_source_local_file.go ├── data_source_local_file_test.go ├── .... other files └── testdata └── TestLocalFileDataSource ├── local_file ├── main.tf
data_source_local_file_test.go
When attempting to reference the
local_file
file from the terraform config directory, you can't use a relative reference, as the working directory is not set totestdata/TestLocalFileDataSource
.main.tf
(error)main.tf
(success)Proposal
We should copy the contents of
ConfigDirectory
to the root of the working directory that terraform will run in. This may have compatibility concerns? Open to other suggestions.At the very least, we should document that this behavior exists if we opt not to fix it.
The text was updated successfully, but these errors were encountered: