Skip to content

Terraform test crashes if you dont specify outputs for override_module #34562

@coin-op

Description

@coin-op

Terraform Version

1.7.0

Terraform Configuration Files

some_module/main.tf

resource "azurerm_resource_group" "resource_group" {
  name     = var.name
  location = var.location
}

some_module/output.tf

output "name" {
  value       = azurerm_resource_group.resource_group.name
  depends_on  = [azurerm_resource_group.resource_group]
  description = "The name of the resource group."
}

another_separate_module/main.tf

module "rg_module" {
   source   = "../some_module"
   name    = "some-name"
   location = "EastUS2"
}


another_separate_module/tests/valid_name.tftest.hcl
```terraform
provider "azurerm" {
  features {}
}

override_module  {
  target = module.rg_module
}

Debug Output

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

HasAttribute on non-object Type
goroutine 313 [running]:
runtime/debug.Stack()
/opt/hostedtoolcache/go/1.21.5/x64/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
/opt/hostedtoolcache/go/1.21.5/x64/src/runtime/debug/stack.go:16 +0x13
github.com/hashicorp/terraform/internal/logging.PanicHandler()
/home/runner/work/terraform/terraform/internal/logging/panic.go:58 +0x13b
panic({0x2cbad60?, 0x3ac11f0?})
/opt/hostedtoolcache/go/1.21.5/x64/src/runtime/panic.go:920 +0x270
github.com/zclconf/go-cty/cty.Type.HasAttribute({{0x0?, 0x0?}}, {0xc0008f74c8?, 0xc0010589a0?})
/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.14.1/cty/object_type.go:157 +0x85
github.com/hashicorp/terraform/internal/terraform.(*Graph).checkAndApplyOverrides.func1({{{0x0?, 0x0?}}, {0x0?, 0x0?}})
/home/runner/work/terraform/terraform/internal/terraform/graph.go:199 +0x69
github.com/hashicorp/terraform/internal/terraform.(*Graph).checkAndApplyOverrides(0xc0010a3040?, 0xc000c66ea0, {0x3142be0?, 0xc0016d99e0})
/home/runner/work/terraform/terraform/internal/terraform/graph.go:214 +0x4c2
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x3142be0?, 0xc0016d99e0})
/home/runner/work/terraform/terraform/internal/terraform/graph.go:79 +0x37b
github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc0016d9aa0, {0x3142be0, 0xc0016d99e0}, 0xc00171e8c0)
/home/runner/work/terraform/terraform/internal/dag/walk.go:384 +0x2e5
created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update in goroutine 215
/home/runner/work/terraform/terraform/internal/dag/walk.go:307 +0xde8

Expected Behavior

A check to say you must specify outputs for override_module

Actual Behavior

terraform cli crashed.

Steps to Reproduce

  1. terraform init
  2. terraform test

Additional Context

No response

References

No response

Metadata

Metadata

Assignees

Labels

bugconfirmeda Terraform Core team member has reproduced this issueterraform test

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions