Loading...
Loading...
### Terraform Version ```shell Terraform v1.13.0 on darwin_arm6 ``` ### Terraform Configuration Files # Successful setup ✅ **structure** ``` . ├── providers.tf └── tests ├── modules │ └── test-setup │ └── main.tf └── my-test.tftest.hcl 4 directories, 3 file ``` **providers.tf** ```hcl terraform { required_providers { null = { source = "hashicorp/null" version = "3.2.4" } } } resource "null_resource" "test" { } ``` **my-test.tftest.hcl** ```hcl run "success" { module { source = "./tests/modules/test-setup" } command = plan assert { condition = fileexists("${path.module}/main.tf") error_message = "Unexpected ${path.module}." } } ``` **main.tf** ```hcl terraform { required_providers { null = { source = "hashicorp/null" } } } resource "null_resource" "test" { } ``` # Unsuccessful setup ❌ **structure** ``` . ├── providers.tf └── integration-tests ├── modules │ └── test-setup │ └── main.tf └── my-test.tftest.hcl 4 directories, 3 file ``` **providers.tf** ```hcl terraform { required_providers { null = { source = "hashicorp/null" version = "3.2.4" } } } resource "null_resource" "test" { } ``` **my-test.tftest.hcl** ```hcl run "success" { module { source = "./integration-tests/modules/test-setup" } command = plan assert { condition = fileexists("${path.module}/main.tf") error_message = "Unexpected ${path.module}." } } ``` **main.tf** ```hcl terraform { required_providers { null = { source = "hashicorp/null" } } } resource "null_resource" "test" { } ``` ### Debug Output ``` 2025-08-26T09:21:53.956+0200 [INFO] Terraform version: 1.13.0 2025-08-26T09:21:53.956+0200 [DEBUG] using github.com/hashicorp/go-tfe v1.74.1 2025-08-26T09:21:53.956+0200 [DEBUG] using github.com/hashicorp/hcl/v2 v2.24.0 2025-08-26T09:21:53.956+0200 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1 2025-08-26T09:21:53.956+0200 [DEBUG] using github.com/zclconf/go-cty v1.16.3 2025-08-26T09:21:53.956+0200 [INFO] Go runtime version: go1.24.5 2025-08-26T09:21:53.956+0200 [INFO] CLI args: []string{"terraform", "test", "-test-directory=integration-tests"} 2025-08-26T09:21:53.956+0200 [TRACE] Stdout is a terminal of width 170 2025-08-26T09:21:53.956+0200 [TRACE] Stderr is a terminal of width 170 2025-08-26T09:21:53.956+0200 [TRACE] Stdin is a terminal 2025-08-26T09:21:53.956+0200 [DEBUG] Attempting to open CLI config file: /Users/####/.terraformrc 2025-08-26T09:21:53.956+0200 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. 2025-08-26T09:21:53.956+0200 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins 2025-08-26T09:21:53.956+0200 [DEBUG] ignoring non-existing provider search directory /Users/####/.terraform.d/plugins 2025-08-26T09:21:53.956+0200 [DEBUG] ignoring non-existing provider search directory /Users/####/Library/Application Support/io.terraform/plugins 2025-08-26T09:21:53.956+0200 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins 2025-08-26T09:21:53.957+0200 [INFO] CLI command args: []string{"test", "-test-directory=integration-tests"} ``` ### Expected Behavior Successfully runs test in both cases ### Actual Behavior Fails with error ``` │ Error: Module not installed │ │ on integration-tests/my-test.tftest.hcl line 3, in run "success": │ 3: module { │ │ This module is not yet installed. Run "terraform init" to install all modules required by this configuration. ``` ### Steps to Reproduce Use setup from `Successful setup ✅` 1. terraform init 2. terraform test **=>** Works as expected. Use setup from `Unsuccessful setup ❌` 1. terraform init 2. terraform test -test-directory=integration-tests **=>** Throws error. ### Additional Context - I tried changing the path of the module in different variations. Nothing worked. - My initial use case is that I wanted to create a helper module as [described here](https://developer.hashicorp.com/terraform/tutorials/configuration-language/test#create-a-new-helper-module) - The differing directory name `integration-test` results from my idea to split integration test which do an actual `apply` and unit tests which would only perform a `plan`. This way I could keep my test types separated, my code base clean and I'm able to control the execution in my pipeline ### References _No response_ ### Generative AI / LLM assisted development? _No response_
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.