The thothctl inventory command creates, manages, and updates inventories of your infrastructure components. This command helps you track modules, their versions, sources, and dependencies, providing valuable insights into your infrastructure composition and enabling version management.
Creates an inventory of Infrastructure as Code (IaC) components in your project.
thothctl inventory iac [OPTIONS]Options:
-ft, --framework-type [auto|terraform|terragrunt|terraform-terragrunt]: Framework type to analyze (default: auto)-iph, --inventory-path PATH: Path for saving inventory reports (default: ./Reports/Inventory)-ch, --check-versions: Check remote versions-updep, --update-dependencies-path: Pass the inventory json file path for updating dependencies-auto, --auto-approve: Use with --update_dependencies option for auto approve updating dependencies-iact, --inventory-action [create|update|restore]: Action for inventory tasks (default: create)--report-type, -r [html|json|all]: Type of report to generate (default: html)
Detailed documentation for inventory iac
thothctl inventory iacThis creates an inventory of all IaC components in the current directory and generates an HTML report in the default location (./Reports/Inventory).
thothctl inventory iac --check-versionsThis creates an inventory and checks if the modules are using the latest available versions.
thothctl inventory iac --report-type jsonThis creates an inventory and generates a JSON report.
thothctl inventory iac --report-type allThis creates an inventory and generates both HTML and JSON reports.
The command supports different IaC frameworks:
thothctl inventory iac --framework-type autoThis automatically detects the framework type based on the files in your project.
thothctl inventory iac --framework-type terraformThis analyzes only Terraform files (.tf) in your project.
thothctl inventory iac --framework-type terragruntThis analyzes only Terragrunt files (terragrunt.hcl) in your project, excluding .terragrunt-cache directories.
thothctl inventory iac --framework-type terraform-terragruntThis analyzes both Terraform and Terragrunt files in your project.
The command supports three main actions:
thothctl inventory iac --inventory-action createThis action scans your IaC files and creates a new inventory.
thothctl inventory iac --inventory-action update --inventory-path ./path/to/inventory.jsonThis action updates your IaC files based on the inventory. It can be used to apply version updates or other changes.
thothctl inventory iac --inventory-action restore --inventory-path ./path/to/inventory.jsonThis action restores your IaC files to the state recorded in the inventory.
The command generates detailed reports about your infrastructure components:
The HTML report includes:
- Project overview and framework type
- Module list with versions and sources
- Dependency graph visualization
- Version status (latest vs. current)
- File locations
The JSON report contains structured data about your infrastructure:
{
"version": 2,
"projectName": "my-project",
"projectType": "terragrunt",
"components": [
{
"path": "./modules",
"components": [
{
"type": "terragrunt_module",
"name": "vpc",
"version": ["3.14.0"],
"source": ["terraform-aws-modules/vpc/aws"],
"file": "modules/terragrunt.hcl",
"latest_version": "5.19.0",
"source_url": "https://registry.terraform.io/v1/modules/terraform-aws-modules/vpc/aws",
"status": "Outdated"
}
]
}
]
}Create an inventory to audit your infrastructure components:
thothctl inventory iac --check-versions --report-type allIdentify outdated modules and update them:
# First create an inventory with version checking
thothctl inventory iac --check-versions --report-type json
# Then update modules to latest versions
thothctl inventory iac --inventory-action update --inventory-path ./Reports/Inventory/InventoryIaC_20250602_121227.jsonGenerate documentation about your infrastructure:
thothctl inventory iac --report-type htmlCreate regular inventories for disaster recovery purposes:
thothctl inventory iac --report-type all --inventory-path ./backups/$(date +%Y-%m-%d)thothctl inventory iacthothctl inventory iac --framework-type terragruntthothctl inventory iac --check-versions --report-type all --inventory-path ./docs/inventory# First create an inventory with version checking
thothctl inventory iac --check-versions --report-type json
# Then update modules to latest versions
thothctl inventory iac --inventory-action update --inventory-path ./Reports/Inventory/InventoryIaC_20250602_121227.jsonthothctl inventory iac --inventory-action restore --inventory-path ./backups/2023-01-01/inventory.json- Regular Inventories: Create inventories regularly to track changes over time
- Version Checking: Use
--check-versionsto identify outdated modules - Multiple Report Types: Use
--report-type allto generate both HTML and JSON reports - Backup Inventories: Store inventories in a version-controlled location
- CI/CD Integration: Add inventory creation to your CI/CD pipeline
- Framework Specification: Explicitly specify the framework type for more accurate results
Warning: No components found in the specified directory.
Solution: Ensure you're running the command in a directory containing Terraform (.tf) or Terragrunt (terragrunt.hcl) files.
Error: Failed to check versions for module xyz
Solution: Ensure you have internet connectivity and the module source is accessible.
Error: Failed to generate HTML report
Solution: Ensure you have write permissions to the output directory.
For more detailed logs, run ThothCTL with the --debug flag:
thothctl --debug inventory iac- thothctl check iac: Check IaC components against best practices
- thothctl scan: Scan infrastructure code for security issues