Background

The Run Terraform Files Query Action performs Steampipe queries on Terraform file resources with a powerful and simple PostgreSQL syntax.

For example, fetching all basic info on Terraform providers can be done simply:

select  name,  alias,  arguments,  pathfrom  terraform_provider;

Get filters for each AWS EC2 AMI:

with filters as (select  name,  type,  jsonb_array_elements(arguments -> 'filter') as filter,  pathfrom  terraform_data_sourcewhere  type = 'aws_ami')select  name,  type,  filter -> 'name' as name,  filter -> 'values' as values,  pathfrom  filters;

A query to list Azure storage accounts that allow public blob access:

  name,  case    when arguments -> 'allow_blob_public_access' is null then false    else (arguments -> 'allow_blob_public_access')::boolean  end as allow_blob_public_access,  pathfrom  terraform_resourcewhere  type = 'azurerm_storage_account'  -- Optional arg that defaults to false  and (arguments -> 'allow_blob_public_access')::boolean;

A full description of all existing tables and official examples are provided here:

Blink’s supported Steampipe version is: v0.3.0.

Usage

Unlike other query actions in Blink, the Run Terraform Files Query is used on static files which need to be fetched and stored during the Automation’s execution before being referenced by the action using the “File Identifier” parameter. The File Identifier can be obtained by running the Create Archive action.

For example, to query data from a Terraform repository:

  1. Clone the repository using the Git Clone action.
  2. Create an archive of the repository using the Create Archive action.
  3. Using the Variable Picker, select the file identifier created in the previous step, and pass it as a parameter to the Run Terraform Cloud Query Action.

Action Parameters

ParameterDescription
SQL statementThe SQL statement we wish to use to query the resource.
File IdentifierThe identifier of a .tar.gz archive from which data will be queried.
Output formatRepresentation of the output result. The possible options are “Table”, “CSV” or “JSON”.