Terraform TUI viewer
Project description
Insight-TF
A terminal-based Terraform dashboard built with Textual โ manage your infrastructure without leaving the command line.
What is Insight-TF?
Insight-TF turns your Terraform workflow into a fully interactive TUI โ browse state, inspect resources, plan, apply, detect drift, estimate costs, and scaffold new resources, all from a single terminal window.
https://github.com/user-attachments/assets/2e3fa276-8a02-405f-b893-262f8dbf1dd8
Features
| Feature | Description |
|---|---|
| ๐ Overview | Terraform version, state serial, total resources, provider count, full resource table |
| ๐ฒ Resource Tree | Resources grouped by type โ click any leaf to inspect all attributes |
| ๐ Plan | Streams real terraform plan output line-by-line |
| โก Apply Now | Runs terraform apply -auto-approve and reloads state on success |
| ๐ฐ Cost Estimate | Real Infracost pricing breakdown by resource with monthly totals |
| ๐ Drift Detection | terraform plan -refresh-only -detailed-exitcode with parsed summary |
| โ Add Resource | 3-step wizard: provider โ 334 AWS resources across 20 categories โ HCL preview |
| ๐๏ธ Destroy | Targeted destroy with confirmation modal before execution |
| ๐ State Reload | Press r to reload state from disk at any time |
Requirements
| Requirement | Version | Notes |
|---|---|---|
| Python | 3.10+ | Required for modern typing syntax |
| Terraform | 1.0+ | Must be in PATH for Plan / Apply / Destroy / Drift |
| Infracost | any | Auto-installed by setup.py for Cost Estimate |
| OS | Linux / macOS / Windows | Tested on Ubuntu 22.04+, macOS 13+ |
Quick Start
1. Clone the repository
git clone https://github.com/yourname/insight-tf.git
cd insight-tf
2. Create a virtual environment
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
3. Run the setup script
python setup.py
The setup script automatically:
- Checks Python 3.10+
- Installs
textualandrich - Checks for Terraform in
PATH - Downloads and installs Infracost for your platform (Linux / macOS / Windows)
- Guides you through Infracost authentication
- Writes
.insight-tf.jsonwith resolved binary paths
4. Launch the app
# From your Terraform project directory (auto-loads terraform.tfstate)
cd ~/my-terraform-project
python /path/to/insight-tf/insight_tf.py
# Or pass the state file path explicitly
python insight_tf.py /path/to/terraform.tfstate
No state file? The app loads built-in sample AWS data so you can explore the UI immediately.
Installation Details
Manual dependency install
pip install textual>=0.47.0 rich>=13.0.0
Infracost manual install
# macOS
brew install infracost
# Linux
curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh
# Authenticate (free โ no credit card required)
infracost auth login
Using a remote state backend
# Terraform Cloud / any backend
terraform state pull > terraform.tfstate
python insight_tf.py
# AWS S3 backend
aws s3 cp s3://your-bucket/env/prod/terraform.tfstate ./terraform.tfstate
python insight_tf.py
Usage Guide
Keyboard Shortcuts
| Key | Action |
|---|---|
1 |
Switch to Overview tab |
2 |
Switch to Manage tab |
r |
Reload state from disk |
q |
Quit |
Esc |
Close any open modal or wizard |
Overview Tab
Displays a high-level snapshot of your infrastructure:
- Terraform version โ read directly from the state file
- State serial โ increments on every apply; useful for auditing
- Total resources โ count of all managed resources
- Provider count โ number of unique providers in use
- Resource table โ type, name, provider, and instance count for every resource
Manage Tab
Resource Tree
The left panel shows all managed resources grouped by type. Click any resource leaf to load its full attribute map in the right panel, including nested maps and lists rendered as structured text.
Action Buttons
โ Add Resource Opens a 3-step wizard:
- Select provider โ AWS supported; Azure, GCP, Oracle, Docker, Kubernetes coming soon
- Browse resources โ 334 AWS resources across 20 categories with live search and category sidebar
- Configure & preview โ fill in fields, review the generated HCL, then choose:
- ๐พ Write File โ saves the
.tffile and runsterraform planto validate - ๐ Write & Apply โ saves the file, plans, then immediately applies
- ๐พ Write File โ saves the
๐ Plan
Streams the full output of terraform plan -no-color into the output panel in real time.
๐ฐ Cost Estimate
Runs infracost breakdown --path . --format json and renders a formatted cost table:
Resource Monthly
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
aws_db_instance.main (db.t3.medium) $ 63.22
aws_instance.web (t3.micro) $ 8.47
aws_s3_bucket.assets usage-based
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
TOTAL MONTHLY ESTIMATE $ 71.69
๐ Detect Drift
Runs terraform plan -refresh-only -detailed-exitcode and reports:
- โ No drift โ infrastructure matches state exactly
- โ ๏ธ Drift found โ lists each drifted resource with its status (changed / deleted outside Terraform / created outside Terraform)
- โ Error โ shows full stderr output for debugging
๐๏ธ Destroy Selected
Select a resource leaf in the tree, click Destroy. A confirmation modal displays the full resource address (type.name) before executing terraform destroy -target=<addr> -auto-approve.
โก Apply Now
Runs terraform apply -auto-approve -no-color from the project directory. Streams all output in real time and automatically reloads the resource tree on success.
AWS Resource Catalog
The Add Resource wizard includes 334 AWS resources across 20 categories:
| Category | Highlights |
|---|---|
| Compute | EC2, Auto Scaling, AMIs, EBS, EIP, placement groups, key pairs |
| Containers | ECS clusters/services/tasks, ECR repositories, EKS clusters/node groups/Fargate |
| Serverless | Lambda functions, aliases, layers, function URLs, event source mappings |
| Storage | S3 (all 13 sub-resources), EFS, FSx (Lustre/Windows/ONTAP), Glacier |
| Database | RDS, Aurora, DynamoDB, ElastiCache, Redshift, Neptune, DocumentDB, MemoryDB, OpenSearch |
| Networking | VPC, subnets, NAT/Internet gateways, Transit Gateway, Direct Connect, flow logs |
| Load Balancing | ALB, NLB, Classic ELB, target groups, listeners, routing rules |
| DNS & CDN | Route 53 (zones/records/health checks/resolver), CloudFront, Global Accelerator |
| IAM & Security | IAM users/groups/roles/policies, KMS, Secrets Manager, SSM, ACM, WAFv2, GuardDuty, Cognito |
| Messaging & Queuing | SQS, SNS, Amazon MQ, Kinesis, MSK Kafka, EventBridge, Pipes |
| Monitoring & Logging | CloudWatch (alarms/dashboards/logs/metrics), X-Ray, CloudTrail, AWS Config |
| API & Integration | API Gateway v1/v2, AppSync GraphQL, Step Functions |
| DevOps & CI/CD | CodeBuild, CodeCommit, CodeDeploy, CodePipeline, CodeArtifact, CloudFormation |
| Machine Learning | SageMaker, Bedrock, Rekognition, Lex v2, Comprehend |
| Data & Analytics | Glue, Athena, EMR, Lake Formation, QuickSight |
| IoT | IoT Core (things/certificates/rules), IoT Events, IoT Analytics |
| Application Services | Elastic Beanstalk, Lightsail, Amplify, App Runner, Batch |
| Cost & Billing | Budgets, Cost Explorer categories, Cost & Usage Reports |
| Migration | DMS replication, DataSync, Migration Hub |
| Management | Organizations, RAM sharing, Resource Groups, SSM maintenance, Service Quotas |
Resources with full guided forms (labelled fields, defaults, placeholders):
aws_s3_bucket ยท aws_instance ยท aws_vpc ยท aws_subnet ยท aws_security_group ยท aws_db_instance ยท aws_iam_role ยท aws_lambda_function
All other resources generate a scaffold HCL block with a direct link to the Terraform registry documentation for that resource type.
Project Structure
insight-tf/
โโโ insight_tf.py # Main application (single file)
โโโ setup.py # Auto-installer for all dependencies
โโโ requirements.txt # Python dependencies
โโโ .insight-tf.json # Generated by setup.py โ binary paths config
โโโ README.md
Architecture overview
| Class | Role |
|---|---|
InsightTF |
Root App โ owns state, _tf_dir, tab switching, state reload |
OverviewPage |
Stat cards + resource summary table |
ManagePage |
Button bar, tree, attribute panel, output log, all action handlers |
ResourceTree |
Textual Tree subclass โ left panel of Manage |
AttributePanel |
Scrollable right panel โ renders full resource attributes |
ProviderSelectScreen |
Modal step 1 โ choose cloud provider |
AWSResourcePickerScreen |
Modal step 2 โ searchable catalog with category sidebar |
AddResourceWizard |
Modal step 3 โ configure fields, preview HCL, write or apply |
ConfirmDestroyScreen |
Modal โ confirmation gate before targeted destroy |
Configuration
.insight-tf.json is written by setup.py and read at startup to locate binaries:
{
"infracost_path": "/usr/local/bin/infracost",
"terraform_path": "/usr/local/bin/terraform",
"setup_complete": true
}
Edit this file manually if your binaries are in non-standard locations.
Extending Insight-TF
Add a guided form for a new resource type
Add an entry to RESOURCE_TEMPLATES in insight_tf.py:
RESOURCE_TEMPLATES["aws_elasticache_cluster"] = {
"description": "ElastiCache Redis/Memcached cluster",
"fields": [
{"name": "resource_name", "label": "Resource name", "placeholder": "my_cache", "required": True, "default": ""},
{"name": "cluster_id", "label": "Cluster ID", "placeholder": "my-redis-cluster","required": True, "default": ""},
{"name": "engine", "label": "Engine", "placeholder": "redis", "required": True, "default": "redis"},
{"name": "node_type", "label": "Node type", "placeholder": "cache.t3.micro", "required": True, "default": "cache.t3.micro"},
{"name": "num_nodes", "label": "Num cache nodes","placeholder": "1", "required": True, "default": "1"},
],
"template": '''resource "aws_elasticache_cluster" "{resource_name}" {{
cluster_id = "{cluster_id}"
engine = "{engine}"
node_type = "{node_type}"
num_cache_nodes = {num_nodes}
}}\n''',
}
Add a new cloud provider
In the PROVIDERS list, add your entry with "supported": True:
{"id": "digitalocean", "name": "DigitalOcean", "icon": "๐", "supported": True},
Then handle the new provider ID in on_provider_selected inside add_resource:
if provider == "digitalocean":
self.app.push_screen(DOResourcePickerScreen(), on_resource_picked)
Replace simulated output with real subprocess calls
All Terraform operations use subprocess.Popen with cwd=self.app._tf_dir. To switch working directories at runtime, pass the project path on launch:
python insight_tf.py /path/to/project/terraform.tfstate
Troubleshooting
MountError: duplicate ID
A widget ID collision โ ensure you are on the latest version. Run git pull and restart.
terraform not found
which terraform # verify it's in PATH
terraform version # verify it runs
infracost not found in Cost Estimate
python setup.py # re-run to auto-install
not authenticated in Cost Estimate
infracost auth login
State not updating after apply / destroy
Press r to manually reload. Ensure your backend writes a local terraform.tfstate or pull remote state first with terraform state pull > terraform.tfstate.
App is slow to open the Add Resource wizard The catalog mounts 334 buttons at once. On very slow terminals, switch to the Manage tab first to let the app fully initialise before clicking Add Resource.
Roadmap
- Multi-workspace support (
terraform workspace list / select) - Azure resource catalog (300+ resources)
- GCP resource catalog
- Kubernetes provider support
-
terraform outputviewer - Module graph visualisation
- Remote state backend selector (S3, Terraform Cloud, GCS, Azure Blob)
- Import existing resources (
terraform import) - State move / rename (
terraform state mv) - Export cost report to CSV / PDF
- Dark / light theme toggle
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and test:
textual run --dev insight_tf.py - Open a pull request with a clear description of what you changed
For new AWS resources, add entries to AWS_RESOURCE_CATALOG. For new guided forms, also add to RESOURCE_TEMPLATES. Please keep both in alphabetical order within their category.
License
MIT โ see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file insight_tf-1.0.0.tar.gz.
File metadata
- Download URL: insight_tf-1.0.0.tar.gz
- Upload date:
- Size: 37.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8d0bc7adda4817f086e88d3a270850677df20c543c323dfe0ff5b02608d5039
|
|
| MD5 |
49fceb211a493fb80abb2992a40342db
|
|
| BLAKE2b-256 |
65312d844e24c9d0ad63524357bb76f308efb00226f0b0ccd13c3f229b3adaa8
|
File details
Details for the file insight_tf-1.0.0-py3-none-any.whl.
File metadata
- Download URL: insight_tf-1.0.0-py3-none-any.whl
- Upload date:
- Size: 32.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffc0b4c1fece0d23c93e1d3175886ede20e20b7ffd3fcada8bdfd57451328bef
|
|
| MD5 |
2f09616cabcdc83058b41ed1ae5bc2b8
|
|
| BLAKE2b-256 |
1dd7da178037cc1ffd80ed62bba8e852697178d3f4df0f8a933e5ab6bf22067a
|