Terraspace all up does not run terraform hooks

I recently created a hook on one stack in my infrastructure that runs before a terraform apply. The hook script sets up a connection required for this particular stack to communicate with the resources it manages. It works great when I run terraspace up <stack_name> but when I try to run terraspace all up <parent_stack_name> the stack fails because the connection is not established. I see no indication in the logs that the hook was triggered.

Am I missing something to enable this behavior or is this a bug?

Unsure. Here’s an example repo put together to test hooks with both terraspace all and terraspace up.

The hook code

app/stacks/demo/config/hooks/terraform.rb

before("apply",
  execute: "echo 'app/stacks/demo/config/hooks/terraform.rb: test stack before hook for terraform apply'",
)

after("apply",
  execute: "echo 'app/stacks/demo/config/hooks/terraform.rb: test stack after hook for terraform apply'"
)

Testing terraspace all

$ terraspace all up -y
Running:
    terraspace up demo # batch 1
Batch Run 1:
Running: terraspace up demo Logs: log/up/demo.log
app/stacks/demo/config/hooks/terraform.rb: test stack before hook for terraform apply
app/stacks/demo/config/hooks/terraform.rb: test stack after hook for terraform apply
terraspace up demo:  Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Time took: 3s
$ grep Hook log/up/demo.log 
[2022-06-11T01:37:47 #16835 terraspace up demo]: Hook: Running terraform before apply hook.
[2022-06-11T01:37:49 #16835 terraspace up demo]: Hook: Running terraform after apply hook.
$

So it looks like the hook is firing.

Testing terraspace up

$ terraspace up demo -y
Building .terraspace-cache/us-west-2/dev/stacks/demo
Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
=> terraform plan -input=false
random_pet.this: Refreshing state... [id=enough-rattler]

No changes. Your infrastructure matches the configuration.


Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.
Hook: Running terraform before apply hook.
=> echo 'app/stacks/demo/config/hooks/terraform.rb: test stack before hook for terraform apply'
app/stacks/demo/config/hooks/terraform.rb: test stack before hook for terraform apply
=> terraform apply -auto-approve -input=false
random_pet.this: Refreshing state... [id=enough-rattler]

No changes. Your infrastructure matches the configuration.


Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Hook: Running terraform after apply hook.
=> echo 'app/stacks/demo/config/hooks/terraform.rb: test stack after hook for terraform apply'
app/stacks/demo/config/hooks/terraform.rb: test stack after hook for terraform apply
Time took: 1s
$

Unsure. Maybe this example repo doesn’t have the set up that triggers the issue. Maybe you can put together a small example repo that reproduces the issue.