turbot/terraform
steampipe plugin install terraform

Table: terraform_module - Query Terraform Modules using SQL

Terraform Modules are a set of Terraform resources that are grouped together and managed as a single entity. They provide a way to encapsulate common service configurations and reuse them across multiple environments or projects. Modules help in managing complex infrastructure setups by breaking them down into smaller, manageable components.

Table Usage Guide

The terraform_module table provides insights into Terraform Modules within Terraform. As a DevOps engineer, explore module-specific details through this table, including source, version, and other metadata. Utilize it to uncover information about modules, such as their configuration, usage across different environments or projects, and the management of complex infrastructure setups.

Important Notes

  • The source argument in a module block tells Terraform where to find the source code for the desired child module. Due to name clashes, the column name for the source argument is module_source.
  • Registry modules support versioning via the version argument.

Examples

Basic info

Explore the different modules in your Terraform configuration to understand their source and version. This can help ensure you're using the most up-to-date and secure modules in your infrastructure.Discover the segments that are using different versions of Terraform modules. This can help in managing updates and ensuring consistency across your infrastructure.

select
name,
module_source,
version
from
terraform_module;
select
name,
module_source,
version
from
terraform_module;

List all modules that reference a source on 'gitlab.com' but don't use a version number as reference

This example highlights the identification of Terraform modules that reference sources on 'gitlab.com' but do not utilize a version number for referencing. This is useful for ensuring proper version control and avoiding potential inconsistencies or conflicts in your infrastructure setup.Explore modules that link to 'gitlab.com' but lack a specified version number. This is useful for identifying potential areas of instability in your infrastructure, as modules without version numbers can introduce unpredictability.

select
name,
split_part(module_source, '=', -1) as ref
from
terraform_module
where
module_source like '%gitlab.com%'
and not split_part(module_source, '=', -1) ~ '^[0-9]';
Error: SQLite does not support split_part function
and regular expression matching like '~'.

Schema for terraform_module

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
argumentsjsonbInput arguments passed to this module.
countbigintThe integer value for the count meta-argument if it's set as a number in a literal expression.
count_srcjsonbThe count meta-argument accepts a whole number, and creates that many instances of the resource or module.
depends_onjsonbUse the depends_on meta-argument to handle hidden data source or module dependencies that Terraform can't automatically infer.
end_linebigintEnding line number.
for_eachjsonbThe for_each meta-argument accepts a map or a set of strings, and creates an instance for each item in that map or set.
module_sourcetextModule source
nametextModule name.
pathtext=Path to the file.
providertextThe provider meta-argument specifies which provider configuration to use for a data source, overriding Terraform's default behavior of selecting one based on the data source type name.
sourcetextThe block source code.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
start_linebigintStarting line number.
versiontextModule version

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- terraform

You can pass the configuration to the command with the --config argument:

steampipe_export_terraform --config '<your_config>' terraform_module