Thursday, April 17, 2025

How to install Checkov | How to Scan Terraform Code for finding security issues using Checkov

 

Checkov is a static code analysis tool designed to scan Infrastructure as Code (IaC) files and identify potential security and compliance misconfigurations. 

How to install Checkov on Linux Ubuntu?

There are several ways to install Checkov on Ubuntu 22.04, but we will be using PIP.

1. Using pip (Recommended):

This is the most common and generally recommended method as it installs the latest stable version and manages dependencies easily.

  • Prerequisites: Ensure you have Python and pip installed. If not, open your terminal and run:

    sudo apt update
    sudo apt install python3-pip -y
    
  • Install Checkov: Once pip is installed, run the following command to install Checkov: 

          sudo pip3 install checkov 
  • Verify Installation: After the installation is complete, you can verify it by checking the Checkov version:

    checkov --version

    This should print the installed Checkov version.


How to Scan Terraform files using Checkov?
Navigate to Terraform directory where you created Terraform files and execute the below command:
For e.g., if you have created terraform files under project-terraform directory, navigate to that dir.

cd project-terraform

Run the below command to scan terraform files:

checkov -d .

Now you will see the issues(if there are any) with TF files like below:


No comments:

Post a Comment

How to install Checkov | How to Scan Terraform Code for finding security issues using Checkov

  Checkov is a static code analysis tool designed to scan Infrastructure as Code (IaC) files and identify potential security and compliance ...