terraform providers— lists provider dependencies discovered from configuration and state.terraform graph— prints Terraform’s internal dependency graph in DOT format (renderable with Graphviz).
terraform providers
Theterraform providers command summarizes provider usage in two places:
- Providers required by configuration — inferred from your
.tffiles and the resource types used. - Providers required by state — referenced in the current state file (this can include providers removed from the configuration after refactors).
- The configuration section shows which providers Terraform will attempt to install for your current
.tffiles. - The state section reveals providers still referenced by state, which helps detect orphaned provider references after refactoring or manual edits.
- Use this command to troubleshoot provider version/source issues (registry vs private mirror), confirm provider sources, and verify policy compliance in enterprise setups.
Run
terraform init before terraform providers if you need Terraform to install or upgrade provider plugins. This command is also helpful when you want to confirm the provider set after a module refactor or a provider source change.terraform graph
Before planning or applying, Terraform builds a directed acyclic graph (DAG) of resources, providers, variables, outputs, and their dependency relationships. The DAG determines create/destroy order and identifies opportunities for parallel execution. Terraform can output this DAG in DOT format. To render it as an image, pipe the output to Graphviz’sdot tool:
dot to be available.
Install Graphviz to render DOT output to PNG or other formats (for example:
brew install graphviz on macOS or apt-get install graphviz on Debian/Ubuntu). See the Graphviz downloads page: https://graphviz.org/download/- Provider nodes (e.g., the AzureRM provider).
- Resource nodes (e.g.,
azurerm_storage_account.example). - Inputs referenced by resources (e.g.,
var.storage_account_name). - Outputs that depend on resources.
- Explicit
depends_onrelationships that you declared.
depends_on entries will appear and enforce ordering where needed.
When to use terraform graph
- Debug complex module interactions and implicit dependencies.
- Diagnose circular dependency errors by visualizing connections.
- Optimize parallelism or add explicit dependencies to control ordering.
- Produce architecture diagrams for documentation or review.
Putting it together
- Use
terraform providersto confirm the set of providers required by your configuration and the state—especially after refactors or provider upgrades. - Use
terraform graph(and Graphviz) to visualize Terraform’s DAG, reason about ordering, and troubleshoot dependency issues.