terrascan
terrascan copied to clipboard
Terrascan not supporting current versions of terraform format_version
- 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''}
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
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?
This is a much needed feature. Not supporting to to new terraform versions make this useful tool useless