I need to use tfsec command in before_hook in order to scan my terraform code
Working condition
terraform {
# Before apply, run script.
before_hook "scan_infra" {
commands = ["apply"]
execute = ["tfsec"]
}
Non working condition
terraform {
# Before apply, run script.
before_hook "scan_infra1" {
commands = ["apply"]
execute = ["tfsec --tfvars-file nsg.tfvars"]
}
# Before apply, run script.
before_hook "scan_infra2" {
commands = ["apply"]
execute = ["tfsec","--tfvars-file", "nsg.tfvars"]
}
throws error like below
:network_security_group tfsec$ terragrunt plan
INFO[0000] Executing hook: before_hook
ERRO[0000] Error running hook before_hook with message: exec: "tfsec --tfvars-file nsg.tfvars": executable file not found in $PATH
ERRO[0000] Errors encountered running before_hooks. Not running 'terraform'.
ERRO[0000] 1 error occurred:
* exec: "tfsec --tfvars-file nsg.tfvars": executable file not found in $PATH
ERRO[0000] Unable to determine underlying exit code, so Terragrunt will exit with error code 1