Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terrascan not supporting current versions of terraform format_version #1571

Open
bekahmark12 opened this issue Jun 6, 2023 · 2 comments
Open

Comments

@bekahmark12
Copy link

bekahmark12 commented Jun 6, 2023

  • terrascan version: 1.18.1
  • terraform version: 1.4.2
  • terraform format version: 1.1

Description

My infrastructure is built using terraform files and uses terragrunt for remote backend management. As such, according to issue #251, I must run terrascan on a terraform plan file. Running on any plan file produces the error
error cli/run.go:141 scan run failed{error 26 0 invalid terraform json file; error: 'terraform format version shoule be one of '0.1, 0.2''}

This has been mentioned previously in issues #980 and #1483 and does not appear to have a resolution.

As many infrastructures nowadays are shifting over to DRY backend management with services like Terragrunt, I believe this will be a critical issue to fix as this is currently the only way I have found to use terrascan with terragrunt. This outdated format_version error is completely stopping our usage of terrascan.

What I Did

I created the terraform plan file in the required json format and ran the terrascan command:
terragrunt show -json tfplan > plan.json
terrascan scan --iac-type tfplan --iac-file plan.json

Error

error cli/run.go:141 scan run failed{error 26 0 invalid terraform json file; error: 'terraform format version shoule be one of '0.1, 0.2''}

@Nathan-Yorio
Copy link

Same issue for me as well.
sed -i -e 's/"format_version":"1.2"/"format_version":"0.2"/g' plan.json
Can manually swap the versions if you still want to try scanning it, but I don't know what the implications are of the version difference

@geanttechnology
Copy link

Same issue for me as well. sed -i -e 's/"format_version":"1.2"/"format_version":"0.2"/g' plan.json Can manually swap the versions if you still want to try scanning it, but I don't know what the implications are of the version difference

This trick worked for me as well. Is there a plan for terrascan to support format_version 1.2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants