π· The Terragrunt website redesign is Work In Progress! π·For a list of outstanding TODOs see this.To give feedback, click here.
list
Usage
The list command helps you discover and display Terragrunt configurations in your codebase. It provides various output formats and options to help you understand the structure and dependencies of your Terragrunt configurations.
Examples
List all units in a typical multi-environment infrastructure setup.
Terminal window
$terragruntlist
live/dev/dblive/dev/ec2live/dev/vpc
live/prod/dblive/prod/ec2live/prod/vpc
List all units in long format, showing unit types and paths.
Terminal window
$terragruntlist-l
TypePath
unitlive/dev/db
unitlive/dev/ec2
unitlive/dev/vpc
unitlive/prod/db
unitlive/prod/ec2
unitlive/prod/vpc
List all units in tree format to visualize the infrastructure hierarchy.
Terminal window
$terragruntlist-T
.
β°ββlive
βββdev
ββββdb
ββββec2
ββ°ββvpc
β°ββprod
βββdb
βββec2
β°ββvpc
List all units with their dependencies to understand infrastructure relationships.
Terminal window
$terragruntlist-l--dependencies
TypePathDependencies
unitlive/dev/dblive/dev/vpc
unitlive/dev/ec2live/dev/db,live/dev/vpc
unitlive/dev/vpc
unitlive/prod/dblive/prod/vpc
unitlive/prod/ec2live/prod/db,live/prod/vpc
unitlive/prod/vpc
List all units in dependency order (DAG) to understand deployment sequence.
Terminal window
$terragruntlist-l--dag--dependencies
TypePathDependencies
unitb-dependency
unita-dependentb-dependency
List all units in dependency order as if running plan command.
The list command supports multiple output formats to help you visualize your Terragrunt configurations in different ways:
Text Format (Default)
The default text format provides a simple, space-separated list of configurations.
It will display all configurations that fit in the width of your terminal. When configurations exceed the width of your terminal, it will wrap to the next line.
Long Format
The long format provides additional details about each configuration, including its type:
Tree Format
The tree format provides a hierarchical view of your configurations:
By default, configurations in tree format are displayed ordered by name and grouped by directory:
Terminal window
.
β°ββlive
βββdev
ββββdb
ββββec2
ββ°ββvpc
β°ββprod
βββdb
βββec2
β°ββvpc
DAG Mode
The list command supports DAG mode to sort and group output based on dependencies using the --dag flag. When using DAG mode, configurations with no dependencies appear first, followed by configurations that depend on them, maintaining the correct dependency order.
For example, in default text format:
Terminal window
# Default alphabetical order
$terragruntlist
a-dependentb-dependency
# DAG mode order
$terragruntlist--dag
b-dependencya-dependent
When using --dag with the tree format, configurations are sorted by dependency order and grouped by relationship in the dependency graph:
Terminal window
$terragruntlist--tree--dag
.
βββlive/dev/vpc
ββββlive/dev/db
βββ°ββlive/dev/ec2
ββ°ββlive/dev/ec2
β°ββlive/prod/vpc
βββlive/prod/db
ββ°ββlive/prod/ec2
β°ββlive/prod/ec2
Queue Construct As
The list command supports the --queue-construct-as flag (or its shorter alias --as) to sort output based on the dependency graph, as if a particular command was run.
This will sort the output based on the dependency graph, as if the plan command was run. All dependent units will appear after the units they depend on.
This will sort the output based on the dependency graph, as if the destroy command was run. All dependent units will appear before the units they depend on.
Note: The --queue-construct-as flag implies the --dag flag.
Dependencies and Discovery
Dependencies
Include dependency information in the output using the --dependencies flag. When combined with different grouping options, this provides powerful ways to visualize your infrastructureβs dependency structure.
External Dependencies
Use the --external flag to discover and include dependencies that exist outside your current working directory. This is particularly useful when working with shared modules or cross-repository dependencies.
Hidden Configurations
By default, Terragrunt excludes configurations in hidden directories (those starting with a dot). Use the --hidden flag to include these configurations in the output.
Working Directory
You can change the working directory for list by using the global --working-dir flag:
Terminal window
terragruntlist--working-dir=/path/to/working/dir
Color Output
When used without any flags, all units and stacks discovered in the current working directory are displayed in colorful text format.
You can disable color output by using the global --no-color flag.
Flags
--format
Format the results as specified. Supported values (text, long, tree). Default: text.
Controls how the list results are displayed:
text (default): Simple space-separated list of configurations. Best for quick overview and scripting.
long: Detailed view showing type (unit/stack), path, and module information. Useful for auditing and documentation.
These values all have shortcuts as standalone flags:
--long / -l for long
--tree / -T for tree
Examples:
Terminal window
# Default text format - Great for quick overview
$terragruntlist
live/dev/dblive/dev/ec2live/dev/vpc
live/prod/dblive/prod/ec2live/prod/vpc
Terminal window
# Long format - Useful for reading structured information quickly
$terragruntlist-l
TypePathDependencies
unitlive/dev/dblive/dev/vpc
unitlive/dev/ec2live/dev/db,live/dev/vpc
unitlive/dev/vpc
unitlive/prod/dblive/prod/vpc
unitlive/prod/ec2live/prod/db,live/prod/vpc
unitlive/prod/vpc
Terminal window
# Tree format - Optimal for visualizing structure
$terragruntlist-T
.
β°ββlive
βββdev
ββββdb
ββββec2
ββ°ββvpc
β°ββprod
βββdb
βββec2
β°ββvpc
The examples above demonstrate a typical multi-environment infrastructure setup with networking, compute, and data layers. Each format provides a different perspective on the same infrastructure, making it easier to understand and manage your Terragrunt configurations.
Type: string
Environment Variables:
TG_FORMAT
--hidden
Include hidden directories in list results.
Controls whether hidden directories (those starting with a dot) are included in the list results.
By default, Terragrunt excludes hidden directories from the list output to reduce noise and focus on your primary infrastructure components. However, there may be cases where you want to see all configurations, including those in hidden directories.
Example:
Terminal window
$terragruntlist-l
TypePath
stackstack
unitunit
Terminal window
$terragruntlist-l--hidden
TypePath
unit.hide/unit
stackstack
unitunit
Type: boolean
Environment Variables:
TG_HIDDEN
--dependencies
Include dependencies in list results.
Controls whether dependency information is included in the list output. When enabled, Terragrunt will analyze and display the dependency relationships between configurations.
This flag is particularly powerful when combined with different output formats and sorting options:
With --format=long: Shows dependencies in a tabular format
With --format=json: Includes full dependency ancestry in JSON output
Type: boolean
Environment Variables:
TG_DEPENDENCIES
--external
Discover external dependencies from initial results.
Controls whether Terragrunt should discover and include external dependencies in the list results. External dependencies are Terragrunt configurations that are referenced by your configurations but exist outside the current working directory.
This flag is most useful when:
Investigating the complete dependency graph of your infrastructure
A shorthand flag that sets --format=tree. Displays the list results in a hierarchical tree structure that shows the relationships between your Terragrunt configurations.
Type: boolean
Aliases:
-T
Environment Variables:
TG_TREE
--long
Output in long format.
A shorthand flag that sets --format=long. Displays the list results in a detailed tabular format that includes additional information about each configuration.
Type: boolean
Aliases:
-l
Environment Variables:
TG_LONG
--dag
Output in DAG mode.
Outputs configurations in DAG mode, which sorts configurations by dependency order and groups them by relationship in the dependency graph.
Examples:
By default, configurations are sorted alphabetically:
Terminal window
$terragruntlist
live/dev/dblive/dev/ec2live/dev/vpc
live/prod/dblive/prod/ec2live/prod/vpc
When the --dag flag is used, configurations are sorted by dependency order (dependencies before their dependents):
Terminal window
$terragruntlist--dag
live/dev/vpclive/prod/vpclive/dev/db
live/prod/dblive/dev/ec2live/prod/ec2
When not used in the long format:
Terminal window
$terragruntlist-l--dependencies
TypePathDependencies
unitlive/dev/dblive/dev/vpc
unitlive/dev/ec2live/dev/db,live/dev/vpc
unitlive/dev/vpc
unitlive/prod/dblive/prod/vpc
unitlive/prod/ec2live/prod/db,live/prod/vpc
unitlive/prod/vpc
Results are sorted by name.
When combined with the long format:
Terminal window
$terragruntlist-l--dependencies--dag
TypePathDependencies
unitlive/dev/vpc
unitlive/prod/vpc
unitlive/dev/dblive/dev/vpc
unitlive/prod/dblive/prod/vpc
unitlive/dev/ec2live/dev/db,live/dev/vpc
unitlive/prod/ec2live/prod/db,live/prod/vpc
When not used in the tree format:
Terminal window
$terragruntlist-T
.
β°ββlive
βββdev
ββββdb
ββββec2
ββ°ββvpc
β°ββprod
βββdb
βββec2
β°ββvpc
When combined with the tree format:
Terminal window
$terragruntlist-T--dag
.
βββlive/dev/vpc
ββββlive/dev/db
βββ°ββlive/dev/ec2
ββ°ββlive/dev/ec2
β°ββlive/prod/vpc
βββlive/prod/db
ββ°ββlive/prod/ec2
β°ββlive/prod/ec2
Type: boolean
Environment Variables:
TG_DAG
--queue-construct-as
Sort output based on the dependency graph, as if a particular command was run. This flag implies the `--dag` flag.
The flag has a shorter alias `--as`.
Sort output based on the dependency graph, as if a particular command was run. This flag implies the --dag flag.
The flag has a shorter alias --as.
Usage
Terminal window
--queue-construct-as=COMMAND
--as=COMMAND
Where COMMAND is the command to simulate (e.g., plan, destroy).
Examples
Sort output as if running plan command (dependencies after dependents):
Terminal window
terragruntfind--queue-construct-as=plan
Sort output as if running destroy command (dependencies before dependents):
Terminal window
terragruntfind--queue-construct-as=destroy
Behavior
When using plan command, all dependent units will appear after the units they depend on.
When using destroy command, all dependent units will appear before the units they depend on.