tenable / terrascan

Detect compliance and security violations across Infrastructure as Code to mitigate risk before provisioning cloud native infrastructure.
https://runterrascan.io
Apache License 2.0
4.67k stars 495 forks source link

Terrascan not supporting current versions of terraform format_version #1571

Open bekahmark12 opened 1 year ago

bekahmark12 commented 1 year ago

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 commented 11 months ago

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 commented 10 months ago

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?

thisurawijesekera commented 1 month ago

This is a much needed feature. Not supporting to to new terraform versions make this useful tool useless