Terraform Files Query
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,
path
from
terraform_provider;
Get filters for each AWS EC2 AMI:
with filters as (
select
name,
type,
jsonb_array_elements(arguments -> 'filter') as filter,
path
from
terraform_data_source
where
type = 'aws_ami'
)
select
name,
type,
filter -> 'name' as name,
filter -> 'values' as values,
path
from
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,
path
from
terraform_resource
where
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:
- Clone the repository using the Git Clone action.
- Create an archive of the repository using the Create Archive action.
- 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
Parameter | Description |
---|---|
SQL statement | The SQL statement we wish to use to query the resource. |
File Identifier | The identifier of a .tar.gz archive from which data will be queried. |
Output format | Representation of the output result. The possible options are "Table", "CSV" or "JSON". |