Terraform Azure Compliance

Run compliance and security controls to detect Terraform Azure resources deviating from security best practices prior to deployment in your Azure subscriptions.


Terraform is an open-source infrastructure as code software tool that provides a consistent CLI workflow to manage hundreds of cloud services.

Steampipe is an open source CLI to instantly query cloud APIs using SQL.

Steampipe Mods are collections of named queries, and codified controls that can be used to test current configuration of your cloud resources against a desired configuration.


Getting started


Download and install Steampipe (https://steampipe.io/downloads). Or use Brew:

brew tap turbot/tap
brew install steampipe

Install the terraform plugin with Steampipe:

steampipe plugin install terraform


git clone https://github.com/turbot/steampipe-mod-terraform-azure-compliance.git


By default, the Terraform plugin configuration loads Terraform configuration files in your current working directory (CWD).

To get started, change your CWD to where your TF files are located:

cd /path/to/tf_files

Then set the STEAMPIPE_WORKSPACE_CHDIR environment variable to the mod directory so Steampipe knows where to load benchmarks from:

export STEAMPIPE_WORKSPACE_CHDIR=/path/to/steampipe-mod-terraform-azure-compliance

Start your dashboard server:

steampipe dashboard

By default, the dashboard interface will then be launched in a new browser window at http://localhost:9194. From here, you can run benchmarks by selecting one or searching for a specific one.

Instead of running benchmarks in a dashboard, you can also run them within your terminal with the steampipe check command.

Run all benchmarks:

steampipe check all

Run all benchmarks for a specific compliance framework using tags:

steampipe check all --tag cft_scorecard_v1=true

Run a benchmark:

steampipe check terraform_azure_compliance.benchmark.storage

Run a specific control:

steampipe check terraform_azure_compliance.control.storage_account_infrastructure_encryption_enabled

When running checks from the CWD, you can also run the steampipe dashboard and steampipe check commands using the --workspace-chdir command line argument:

steampipe dashboard --workspace-chdir=/path/to/steampipe-mod-terraform-azure-compliance
steampipe check all --workspace-chdir=/path/to/steampipe-mod-terraform-azure-compliance

Different output formats are also available, for more information please see Output Formats.


No credentials are required.


If you want to run benchmarks and controls across multiple directories containing Terraform configuration files, they can be run from within the steampipe-mod-terraform-azure-compliance mod directory after configuring the Terraform plugin configuration:

vi ~/.steampipe/config/terraform.spc
connection "terraform" {
plugin = "terraform"
paths = ["/path/to/files/*.tf", "/path/to/nested/files/**/*.tf"]

After setting up your Terraform plugin configuration, navigate to the steampipe-mod-terraform-azure-compliance mod directory and start the dashboard server:

cd /path/to/steampipe-mod-terraform-azure-compliance
steampipe dashboard

For more details on connection configuration, please refer to Terraform Plugin Configuration.

Common and Tag Dimensions

The benchmark queries use common properties (like connection_name and path) and tags that are defined in the form of a default list of strings in the mod.sp file. These properties can be overwritten in several ways:

  • Copy and rename the steampipe.spvars.example file to steampipe.spvars, and then modify the variable values inside that file

  • Pass in a value on the command line:

    steampipe check benchmark.compute --var 'common_dimensions=["connection_name", "path"]'
    steampipe check benchmark.compute --var 'tag_dimensions=["Environment", "Owner"]'
  • Set an environment variable:

    SP_VAR_common_dimensions='["connection_name", "path"]' steampipe check control.compute_vm_azure_defender_enabled
    SP_VAR_tag_dimensions='["Environment", "Owner"]' steampipe check control.compute_vm_azure_defender_enabled


If you have an idea for additional controls or just want to help maintain and extend this mod (or others) we would love you to join the community and start contributing.

Please see the contribution guidelines and our code of conduct. All contributions are subject to the Apache 2.0 open source license.

Want to help but not sure where to start? Pick up one of the help wanted issues: