Hooks and internal variables

Hello,
First of all thanks for the terraspace, it looks impressive.
I’m not familiar with ruby and for me it not clear how can I use internal variables in hooks, for example:

  • options[:instance]
  • outputs(‘stack.output’)
  • helpers: aws_ssm
  • aws account id

Here is what I found and it works, but I can not understand how to use variables above

% cat app/stacks/jobs/config/hooks/terraspace.rb
class EnvExporter
  def call
    puts("Hello: " + Terraspace.root)
    puts("Hello: " + Terraspace.env)
  end
end

before("build",
  execute: EnvExporter
)

thank you in advance for your help

Any ideas how to use terraspace metadata in hooks?

Dug into this. Made some adjustments to the hook runner so more context is available and some metadata is available.

Released in v0.6.7. Also updated docs with an example:

There’s also a note on the docs about other helper methods like outputs and aws_ssm. Those are not available and would require changes to tfvars depedency graph processing logic. Got some ideas for it, but it’s much more work so unsure when will get to it. PRs are welcome. No sweat either way of course. :grin: