【问题标题】:terragrunt before_hook failed to exectute tfsec with passing flags in itterragrunt before_hook 无法执行 tfsec 并在其中传递标志
【发布时间】:2021-07-15 07:43:37
【问题描述】:

我需要在 before_hook 中使用 tfsec 命令来扫描我的 terraform 代码

工作条件

terraform {
      # Before apply, run script.
      before_hook "scan_infra" {
        commands     = ["apply"]
        execute  = ["tfsec"]
      }

非工作状态

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"]
  }

抛出如下错误

: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 

【问题讨论】:

    标签: terraform terragrunt


    【解决方案1】:

    需要指定shell,在tfsec前面加“sh”、“-c”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-20
      • 2021-05-16
      • 2021-06-21
      • 2011-05-29
      • 2018-01-22
      • 1970-01-01
      • 2021-02-14
      • 1970-01-01
      相关资源
      最近更新 更多