CloudGrains logo
infra-guide docs
Back to infra-guide

infra-guide

Interactive Terraform & OpenTofu CLI · v0.2.0 · MIT License

Overview

v0.2.0Python 3.8+MIT LicenseFree Forever

infra-guide is a free, open-source CLI and interactive TUI for Terraform and OpenTofu. It combines a guided menu for beginners with direct subcommands for production use — both powered by the same engine.

Beyond being a menu wrapper, infra-guide adds capabilities that raw Terraform doesn't include: Doctor diagnostics, a built-in security policy engine, a local browser command center, cost insight from plan JSON, drift detection, 5 visual themes, shell completion, and CI/CD pipeline mode.

No telemetry

Zero data collection, works fully offline

No credentials needed

Only wraps your local Terraform / OpenTofu binary

Auto-detects binary

Finds Terraform or OpenTofu automatically

MIT License

Free forever, source code on GitHub

Prerequisites

Before installing infra-guide, you need the following on your system:

RequirementVersionCheck
Python3.8+python3 --version
Terraform or OpenTofuAnyterraform version
No cloud credentials requiredinfra-guide wraps your local Terraform/OpenTofu binary. It does not need AWS, GCP, or Azure credentials. Your cloud config stays wherever Terraform expects it.

Install Terraform or OpenTofu

You only need one of these — infra-guide auto-detects which one is available.

Installation

pip (standard)

The simplest way — works on any system with Python 3.8+.

bash
pip install infra-guide

pipx (recommended)

pipx installs infra-guide in an isolated environment so it never conflicts with other Python packages.

bash
# Install pipx if you don't have it
pip install pipx

# Install infra-guide
pipx install infra-guide

From source

bash
git clone https://github.com/cloudgrains/infra-guide.git
cd infra-guide
pip install .

Verify installation

bash
infra-guide --version
If infra-guide is not found after install, ensure ~/.local/bin is in your $PATH. Run python3 -m site --user-base to find the install location.

Quick Start

Run these four commands from any directory containing Terraform or OpenTofu configuration files to get oriented immediately.

1
infra-guide

Open the interactive TUI dashboard

2
infra-guide doctor

Workspace health check — validate config, detect drift

3
infra-guide policy

Run built-in security policy checks on your plan

4
infra-guide web

Open a browser command center at localhost:8765

First runRun infra-guide doctor before anything else. It tells you exactly what's missing, what's configured wrong, and whether drift has been detected — all in one command.

Doctor Mode

Doctor mode runs a full workspace health audit. It validates your configuration, checks the backend, counts variables, verifies provider locks, and — optionally — detects infrastructure drift, all in a single command.

bash
# Basic health check
infra-guide doctor

# Health check + drift detection
infra-guide doctor --with-drift

What it checks

CheckWhat it verifies
Terraform / OpenTofu detectedBinary found in PATH, version reported
Backend configuredbackend block present in config
Providers locked.terraform.lock.hcl exists
Variables setAll required variables have values
WorkspaceCurrent workspace name shown
Drift (--with-drift)State vs actual infra compared

Example output

terminal
$ infra-guide doctor
⚕ Workspace Health
✔ Terraform v1.6.0       detected
✔ Backend configured     S3
✔ Providers locked       .terraform.lock.hcl
✔ Variables set          10 / 10
⚠ Drift detected        2 resources changed

Run `infra-guide plan` to see full diff
Drift detectedWhen doctor reports drift, run infra-guide plan to see what changed before applying anything. Applying over drifted state can cause unexpected resource recreation.

Policy Checks

infra-guide ships a built-in security policy engine. Run infra-guide policy to check your Terraform plan against six security rules — no external tools required.

bash
# Check against saved plan file
infra-guide policy --plan-file tfplan.json

# Run policy check interactively
infra-guide policy

Built-in policies

PolicyWhat it catches
no-public-s3S3 buckets with public access enabled
no-public-ingressSecurity groups with 0.0.0.0/0 ingress
require-tagsResources missing required tags
require-encryptionStorage resources without encryption
s3-versioningS3 buckets without versioning enabled
no-default-vpcResources deployed into the default VPC
Policy checks run against a plan JSON file — they don't run live operations against your cloud. Generate a plan first with infra-guide plan --out tfplan, then run policy checks with infra-guide policy --plan-file tfplan.json.

Web Command Center

infra-guide web launches a local browser interface powered by the same backend as the TUI. Everything you can do in the terminal, you can do from a browser tab.

bash
# Start on default port 8765
infra-guide web

# Use a custom port
infra-guide web --port 9000

# Start server without opening browser
infra-guide web --no-browser

The web UI opens automatically at http://localhost:8765. It shows a dashboard with your workspace status, recent commands, and buttons to run all infra-guide operations.

Local onlyThe web server listens on localhost only. It is not exposed to the network and has no authentication — never port-forward or proxy it to a public interface.

Drift Detection

Drift occurs when someone modifies cloud resources directly (via the console, CLI, or another tool) without updating Terraform. infra-guide can detect this automatically.

bash
# Standalone drift check
infra-guide drift

# Combined with health diagnostics
infra-guide doctor --with-drift

When drift is detected, infra-guide shows which resources changed and what properties differ from the state file. From there, you can run infra-guide plan to see the full diff and decide whether to apply or import the manual changes.

The quickest workflow is infra-guide doctor --with-drift as your daily pre-flight — it combines the health audit and drift check in a single run.

Cost Insight

When you apply with a saved plan file, infra-guide analyses the plan JSON and surfaces AWS cost-impact hints before any changes run. This gives you a rough estimate of what the change will cost before it's irreversible.

bash
# 1. Save a plan
infra-guide plan --out tfplan

# 2. Apply with cost hints shown automatically
infra-guide apply --plan-file tfplan --yes
Cost insight is AWS-only and shows estimates based on resource type and region. It is not a billing guarantee — always check your cloud provider's cost explorer after significant changes.

Themes

infra-guide ships with five visual themes. Your selected theme persists across sessions.

aurora

Default. Blue/purple gradient

sunset

Warm orange/red tones

forest

Natural green palette

mono

Monochrome — minimal noise

neon

High-contrast cyberpunk

Switching themes

bash
# Set theme (persists across sessions)
infra-guide theme --set neon

# List available themes
infra-guide theme --list

# Reset to default (aurora)
infra-guide theme --reset

Shell Completion

infra-guide supports tab completion for bash, zsh, and fish. Setup is a one-time operation per shell.

bash

bash
infra-guide completion bash >> ~/.bashrc
source ~/.bashrc

zsh

bash
infra-guide completion zsh >> ~/.zshrc
source ~/.zshrc

fish

bash
infra-guide completion fish > ~/.config/fish/completions/infra-guide.fish

After setup, press Tab after typing infra-guide to see available subcommands, flags, and their descriptions.

Command History & Favorites

infra-guide logs all commands you run and lets you pin frequently-used ones as favorites.

bash
# View recent command history
infra-guide history

# View favorites only
infra-guide history --favorites

From the history view you can re-run any previous command, add it to favorites, or remove old entries. Favorites are accessible from the TUI main menu.

CI/CD Mode

infra-guide cicd runs a pipeline-safe init → validate → plan sequence in non-interactive mode with machine-readable exit codes. No prompts, no TUI, no user interaction required.

bash
# Run CI/CD pipeline
infra-guide cicd

# Exit codes:
# 0 — success, plan shows no changes
# 1 — error (config/init failure)
# 2 — success, plan shows changes (standard Terraform behavior)

GitHub Actions example

yaml
- name: infra-guide CI
  run: |
    pip install infra-guide
    infra-guide cicd
  env:
    TF_VAR_region: us-east-1
Exit code 2 is not failureExit code 2 means the plan succeeded and there are changes to apply — this is normal Terraform behavior. Only exit code 1 indicates a real error.

Workspaces

Workspaces let you manage multiple environments (dev, staging, prod) from the same configuration. infra-guide wraps Terraform's workspace commands with a cleaner interface.

bash
# List all workspaces (current marked with *)
infra-guide workspace --list

# Create a new workspace
infra-guide workspace --new staging

# Switch to a workspace
infra-guide workspace --select production

# Delete a workspace
infra-guide workspace --delete old-env
Default workspaceDeleting the default workspace is blocked by Terraform — infra-guide will warn you before attempting this.

State Explorer

Explore your Terraform state file without editing it directly. The state explorer shows resources in list, tree, or detail view.

bash
# Overview — resource count by type
infra-guide state

# Tree view — hierarchical by resource type
infra-guide state --tree

# Detailed view of one resource
infra-guide state --show aws_instance.web

State explorer is read-only — it never modifies your state file. Use it to audit what Terraform knows about, find resource addresses, and understand your current infrastructure without running terraform state list manually.

All Commands

Complete reference for every infra-guide subcommand.

CommandDescriptionRisk
infra-guideOpen interactive TUI dashboardLow
infra-guide doctorWorkspace health diagnosticsLow
infra-guide doctor --with-driftHealth check + drift detectionLow
infra-guide statusFast workspace summary panelLow
infra-guide initInitialize providers, modules, backendLow
infra-guide planPreview changesLow
infra-guide plan --out tfplanPreview and save plan to fileLow
infra-guide applyApply changesMedium
infra-guide apply --plan-file tfplan --yesApply with cost insightMedium
infra-guide destroy --yesDelete managed infrastructureHigh
infra-guide policyRun built-in security policy checksLow
infra-guide driftDetect infrastructure driftLow
infra-guide state --treeExplore state fileLow
infra-guide outputShow output valuesLow
infra-guide webLaunch browser command centerLow
infra-guide workspace --listList / manage workspacesLow
infra-guide theme --set neonChange active themeLow
infra-guide cicdPipeline-safe init → validate → planMedium
infra-guide fmtFormat HCL filesLow
infra-guide validatePre-flight validationLow
infra-guide historyRecent commands and favoritesLow
infra-guide completion bashShell completion setupLow

FAQ

Does infra-guide work with OpenTofu?

Yes. infra-guide automatically detects whether Terraform or OpenTofu is installed and uses the correct binary. All commands work identically with both tools.

Does infra-guide need internet access?

No. infra-guide works completely offline. It does not call any external APIs, collect telemetry, or require an account. The web command center (infra-guide web) also runs entirely on localhost.

What's the difference between infra-guide and running Terraform directly?

infra-guide adds capabilities you don't get from raw Terraform: Doctor diagnostics, built-in policy checks, drift detection in a single command, cost insight before apply, a browser UI, 5 themes, shell completion, command history, and a guided TUI for beginners — all offline.

Is infra-guide free?

Yes, completely free and open source under the MIT License. No paid tiers, no SaaS fees, no API keys.

infra-guide is not found after pip install — how do I fix this?

The pip user scripts directory may not be in your PATH. Run python3 -m site --user-base to find it, then add <user-base>/bin to your PATH in ~/.bashrc or ~/.zshrc. Using pipx install infra-guide avoids this entirely.

Contributing

Contributions are welcome. Here's how to get started:

bash
# 1. Fork and clone
git clone https://github.com/cloudgrains/infra-guide.git
cd infra-guide

# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate

# 3. Install in dev mode
pip install -e ".[dev]"

# 4. Run tests
pytest

# 5. Format code
black infra_guide/

Open a Pull Request from your fork targeting the main branch. Please include test coverage for new features.

Made by CloudGrains · Kolhapur, India · MIT License