I have multiple environment Testing and Production ,I want to verify terragrunt run-all plan(plan) with checkov when GitHubActions workflow is triggered.I want the plan saved in tfplan.binary then converted to json so checkov can scan it.I am getting error message after the terraform run-all plan is called.Below is my code snippet and the error messages.
Terragrunt.hcl
terraform {
extra_arguments "plan_file" {
commands = ["plan"]
arguments = ["-out=${get_terragrunt_dir()}/tfplan.binary"]
}
after_hook "after_hook_plan" {
commands = ["plan"]
execute = ["sh", "-c", "terraform show -json tfplan.binary > ${get_parent_terragrunt_dir()}/plan.json"]
}
}
Actions Workflow
- name: Plan
id: plan
run: |
terragrunt run-all plan -no-color --terragrunt-non-interactive
- run: |
pip install checkov
checkov -d ../../
- name: 'Test Plan (Checkov)'
uses: bridgecrewio/checkov-action@master
with:
directory: ../../
quiet: false # optional: display only failed checks
framework: terraform # optional: run only on a specific infrastructure {cloudformation,terraform,kubernetes,all}
output_format: json # optional: the output format, one of: cli, json, junitxml, github_failed_only
error message
Saved the plan to: /home/runner/work/identity/identity/applied/accounts/production/global/tfplan.binary
To perform exactly these actions, run the following command to apply:
terraform apply "/home/runner/work/identity/identity/applied/accounts/production/global/tfplan.binary"
time=2022-01-17T15:26:44Z level=error msg=Module /home/runner/work/identity/identity/applied/accounts/testing/global has finished with an error: 1 error occurred:
* exit status 1
prefix=[/home/runner/work/identity/identity/applied/accounts/testing/global]
time=2022-01-17T15:26:44Z level=error msg=Module /home/runner/work/identity/identity/applied/accounts/production/global has finished with an error: 1 error occurred:
* exit status 1
time=2022-01-17T15:26:42Z level=info msg=Executing hook: after_hook_plan prefix=[/home/runner/work/identity/identity/applied/accounts/production/global]
time=2022-01-17T15:26:44Z level=error msg=Error running hook after_hook_plan with message: exit status 1 prefix=[/home/runner/work/identity/identity/applied/accounts/production/global]