Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform test crash when using module.source #33586

Closed
drewmullen opened this issue Jul 26, 2023 · 4 comments · Fixed by #33589
Closed

terraform test crash when using module.source #33586

drewmullen opened this issue Jul 26, 2023 · 4 comments · Fixed by #33589
Assignees
Labels
bug confirmed a Terraform Core team member has reproduced this issue explained a Terraform Core team member has described the root cause of this issue in code

Comments

@drewmullen
Copy link
Contributor

drewmullen commented Jul 26, 2023

Terraform Version

./tftest -version                                           
Terraform v1.6.0-alpha20230719
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.9.0
+ provider registry.terraform.io/hashicorp/awscc v0.56.0

Terraform Configuration Files

run "validate_locals" {
  command = plan

  module {
    source = "./examples/public_private_flow_logs"
  }

  assert {
    condition = local.myval == "drew"
    error_message = "its not drew"
  }
}

Debug Output

./tftest test                       

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

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

[1]: https://github.com/hashicorp/terraform/issues

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

no expansion has been registered for module.test
goroutine 473 [running]:
runtime/debug.Stack()
        /Users/runner/hostedtoolcache/go/1.20.4/x64/src/runtime/debug/stack.go:24 +0x64
runtime/debug.PrintStack()
        /Users/runner/hostedtoolcache/go/1.20.4/x64/src/runtime/debug/stack.go:16 +0x1c
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        /Users/runner/work/terraform/terraform/internal/logging/panic.go:58 +0x170
panic({0x1049bd780, 0x1400638a020})
        /Users/runner/hostedtoolcache/go/1.20.4/x64/src/runtime/panic.go:890 +0x258
github.com/hashicorp/terraform/internal/instances.(*expanderModule).moduleInstances(0x1400698fb00, {0x140008696d0, 0x4, 0x5}, {0x14001dee8f0, 0x0, 0x4}, 0x0)
        /Users/runner/work/terraform/terraform/internal/instances/expander.go:370 +0x22c
github.com/hashicorp/terraform/internal/instances.(*Expander).expandModule(0x245700?, {0x140008696d0?, 0x14001dee9d8?, 0x10260d1e8?}, 0xd8?)
        /Users/runner/work/terraform/terraform/internal/instances/expander.go:126 +0x108
github.com/hashicorp/terraform/internal/instances.(*Expander).ExpandModule(...)
        /Users/runner/work/terraform/terraform/internal/instances/expander.go:105
github.com/hashicorp/terraform/internal/terraform.(*nodeExpandModule).Execute(0x14005ffa210, {0x104ef0f58, 0x140024dc620}, 0xb0?)
        /Users/runner/work/terraform/terraform/internal/terraform/node_module_expand.go:112 +0x7c
github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0x14004aa6240, {0x104ef0f58, 0x140024dc620}, {0x12e4b1820, 0x14005ffa210})
        /Users/runner/work/terraform/terraform/internal/terraform/graph_walk_context.go:143 +0xa8
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x104c75340, 0x14005ffa210})
        /Users/runner/work/terraform/terraform/internal/terraform/graph.go:78 +0x238
github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0x1400277a180, {0x104c75340, 0x14005ffa210}, 0x14000f79d80)
        /Users/runner/work/terraform/terraform/internal/dag/walk.go:384 +0x2dc
created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update
        /Users/runner/work/terraform/terraform/internal/dag/walk.go:307 +0xb7c

Expected Behavior

test should plan the root module located in ./examples/public_private_flow_logs then run assert statements against it

Actual Behavior

crash

Steps to Reproduce

$ git clone git@github.com:drewmullen/terraform-aws-vpc-1.git
$ cd terraform-aws-vpc-1
$ git checkout terraform-test-native
$ terraform init
$ terraform test 

Additional Context

im sure yall went back and forth on this but, initially i set source = "../examples/" since that is the relative path to my tests dir. Not saying you should change it but... that was my initial thought

References

No response

@drewmullen drewmullen added bug new new issue not yet triaged labels Jul 26, 2023
@drewmullen
Copy link
Contributor Author

drewmullen commented Jul 26, 2023

Note: I thought this might be due to the fact that the source i point at doesnt have the local defined (dont hate me, im just trying this feature out :D). However, i tried adding the local to that root and still get a crash

In case its helpful, heres the PR im using to track my various tests: aws-ia/terraform-aws-vpc#127

@drewmullen drewmullen changed the title terraform test crash when using module.source1 terraform test crash when using module.source Jul 26, 2023
@drewmullen
Copy link
Contributor Author

I also just noticed that the example dir has a module source pointing to the hashi registry, i tried changing that to relative path back to the root, same crash

module "vpc" {
  # source  = "aws-ia/vpc/aws"
  # version = ">= 4.2.0"
  source = "../.."

@liamcervante liamcervante self-assigned this Jul 26, 2023
@liamcervante liamcervante added the confirmed a Terraform Core team member has reproduced this issue label Jul 26, 2023
@liamcervante
Copy link
Member

Hi @drewmullen, thanks for finding another bug!

I can confirm I can replicate this. From what I can tell the cause of this seems to be modules loaded from run blocks referencing child modules.

We'll get this fixed for the next prerelease!

@liamcervante liamcervante added the explained a Terraform Core team member has described the root cause of this issue in code label Jul 26, 2023
@liamcervante liamcervante removed the new new issue not yet triaged label Jul 31, 2023
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed a Terraform Core team member has reproduced this issue explained a Terraform Core team member has described the root cause of this issue in code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants