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 thesource
argument ismodule_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, versionfrom terraform_module;
select name, module_source, versionfrom 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 reffrom terraform_modulewhere module_source like '%gitlab.com%' and not split_part(module_source, '=', -1) ~ '^[0-9]';
Error: SQLite does not support split_part functionand regular expression matching like '~'.
Schema for terraform_module
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
arguments | jsonb | Input arguments passed to this module. | |
count | bigint | The integer value for the count meta-argument if it's set as a number in a literal expression. | |
count_src | jsonb | The count meta-argument accepts a whole number, and creates that many instances of the resource or module. | |
depends_on | jsonb | Use the depends_on meta-argument to handle hidden data source or module dependencies that Terraform can't automatically infer. | |
end_line | bigint | Ending line number. | |
for_each | jsonb | The 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_source | text | Module source | |
name | text | Module name. | |
path | text | = | Path to the file. |
provider | text | The 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. | |
source | text | The block source code. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
start_line | bigint | Starting line number. | |
version | text | Module 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