Synopsis
Show all declared modules in a working directoryUsage
Description
Theterraform modules command prints out a list of all declared Terraform modules and their resolved versions in a Terraform working directory. This command analyzes the configuration to identify all module declarations and resolves their sources and versions from the module manifest.
The command reads the root module configuration, traverses the module tree, and displays information about each module including its source, version constraints, and resolved version.
Prerequisites
Before running this command, you must:- Have a valid Terraform configuration in the working directory
- Run
terraform initto install module dependencies
terraform init.
Options
If specified, output declared Terraform modules and their resolved versions in a machine-readable JSON format instead of human-readable output.Default:
falseOutput Formats
Human-readable format (default)
Displays modules in a tree-like structure with their sources and versions.JSON format
Provides structured JSON output containing detailed information about each module, including:- Module key/path
- Source address
- Version constraints
- Resolved version
- Module references
Exit Codes
- 0 - Success
- 1 - Errors occurred (e.g., configuration errors, uninstalled modules, core version requirement failures)
Examples
List modules in human-readable format
List modules in JSON format
Error when modules are not installed
terraform init has not been run: