CloudGrains logo
Back to infra-guide

infra-guide πŸš€

MIT LicensePython 3.8+Version 0.2.0

infra-guide is a production-grade, interactive terminal UI (TUI) tool for Terraform and OpenTofu that combines beginner-friendly guidance with enterprise-level features. Learn infrastructure-as-code while using professional tools like drift detection, policy validation, and CI/CD integration.

✨ Features

Core Features

  • 🎯 Auto-Detection: Automatically detects whether you have Terraform or OpenTofu installed
  • πŸ“š Interactive Guides: Detailed explanations for each command before execution
  • 🎨 Beautiful TUI: Rich, colorful interface with a modern dark theme
  • ⚑ No Setup Required: No cloud credentials, no network calls, no telemetry
  • πŸ›‘οΈ Safety First: Confirmation prompts and warnings before destructive operations
  • πŸ“– Beginner-Friendly: Best practices and common flags explained clearly

Enterprise Features (v0.2.0) πŸ†•

  • πŸ” Drift Detection: Automatically detect when infrastructure has drifted from state
  • βœ… Pre-Flight Validation: Comprehensive checks before executing commands
  • πŸ“¦ State Explorer: Interactive browser for exploring state files with tree view
  • πŸ“ Workspace Manager: Easy management of multiple environments
  • πŸš€ CI/CD Mode: Non-interactive pipeline mode for automation
  • πŸ“Š Resource Visualization: View resources by type with detailed statistics
  • πŸ”„ Smart Validation: Syntax checking, format validation, and configuration analysis

🎬 Demo

πŸš€ infra-guide - Interactive Infrastructure Guide
πŸ“¦ Using: terraform (v1.6.0)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ Main Menu - Enhanced Edition ───────────────────┐
β”‚ Option  Command      Description                                     β”‚
β”‚ 1       init         πŸ”§ Initialize a working directory               β”‚
β”‚ 2       plan         πŸ“‹ Show changes required                        β”‚
β”‚ 3       apply        βœ… Create or update infrastructure              β”‚
β”‚ 4       destroy      πŸ’₯ Destroy infrastructure                       β”‚
β”‚ 5       validate     βœ“ Run pre-flight validations                   β”‚
β”‚ 6       drift        πŸ” Detect infrastructure drift                  β”‚
β”‚ 7       state        πŸ“¦ Explore state file                           β”‚
β”‚ 8       workspace    πŸ“ Manage workspaces                            β”‚
β”‚ 9       cicd         πŸš€ CI/CD pipeline mode                          β”‚
β”‚ 0       exit         πŸšͺ Exit infra-guide                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Select an option [1/2/3/4/5] (5):

πŸ“‹ Prerequisites

Before installing infra-guide, ensure you have:

1. Python 3.8 or higher

python3 --version

2. Either Terraform OR OpenTofu (at least one required)

Note: No cloud credentials, API keys, or additional setup needed!

πŸš€ Installation

Option 1: Install with pipx (Recommended)

pipx installs Python applications in isolated environments, preventing dependency conflicts.

Install pipx if you don't have it:

sudo apt update
sudo apt install pipx

Install infra-guide:

pipx install infra-guide

Run the tool:

infra-guide

Option 2: Install from Source

For development or to contribute to the project.

# Clone the repository
git clone https://github.com/cloudgrains/infra-guide.git
cd infra-guide

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

# Install the package
pip install .

Option 3: Install from GitHub (Development Version)

# Install directly from GitHub using pipx
pipx install git+https://github.com/cloudgrains/infra-guide.git

# Or from source directory
git clone https://github.com/cloudgrains/infra-guide.git
cd infra-guide
pip install -e .

πŸ“– Usage

Simply run the command from any directory containing Terraform/OpenTofu configuration files:

infra-guide

Navigation

  • Use number keys (1-5) to select menu options
  • Follow the on-screen prompts
  • Read the guides before executing commands
  • Confirm when prompted before any command execution

Example Workflow

Basic Workflow:

  1. Initialize your project - Select option 1 (init)
  2. Validate configuration - Select option 5 (validate) for pre-flight checks
  3. Preview changes - Select option 2 (plan)
  4. Apply changes - Select option 3 (apply)

Advanced Workflow:

  1. Check for drift - Select option 6 (drift) to detect changes outside Terraform
  2. Explore state - Select option 7 (state) to view current infrastructure
  3. Manage environments - Select option 8 (workspace) to switch between dev/staging/prod
  4. Run CI/CD pipeline - Select option 9 (cicd) for automated validation

🎯 Supported Commands

CommandDescriptionRisk LevelNew in v0.2.0
initInitialize working directory🟒 Low-
planPreview infrastructure changes🟒 Low-
applyCreate/update infrastructure🟑 Medium-
destroyDelete all infrastructureπŸ”΄ High-
validateRun pre-flight checks🟒 Lowβœ…
driftDetect infrastructure drift🟒 Lowβœ…
stateExplore state file🟒 Lowβœ…
workspaceManage workspaces🟑 Mediumβœ…
cicdRun CI/CD pipeline🟑 Mediumβœ…

πŸ’‘ Feature Deep Dive

πŸ” Drift Detection

Automatically detects when your actual infrastructure has diverged from the state file. This happens when changes are made outside of Terraform/OpenTofu (manual changes, other tools, etc.).

# In infra-guide, select option 6
# Shows which resources have drifted and what changed

βœ… Pre-Flight Validation

Runs comprehensive checks before you execute commands:

  • Configuration file existence
  • Initialization status
  • Syntax validation
  • Code formatting
  • Backend configuration
  • Provider version locks
  • Required variables

πŸ“¦ State Explorer

Interactive browser for your state file:

  • Overview: Total resources and types
  • Resource List: All resources with addresses
  • Tree View: Hierarchical visualization by resource type

πŸ“ Workspace Manager

Easily manage multiple environments:

  • List all workspaces
  • Switch between workspaces
  • Create new workspaces
  • Delete unused workspaces
  • Visual indication of current workspace

πŸš€ CI/CD Pipeline Mode

Non-interactive mode perfect for automation:

  • Runs init β†’ validate β†’ plan automatically
  • Uses detailed exit codes
  • No user prompts
  • Designed for continuous integration

πŸ”’ Security & Privacy

No Telemetry

We don't collect any data about your usage

No Network Calls

Works completely offline

No Credentials Required

Only wraps Terraform/OpenTofu CLI

Open Source

Fully transparent, auditable code

Local Execution

All commands run locally on your machine

πŸ› οΈ Development

Setting Up Development Environment

# Clone the repository
git clone https://github.com/cloudgrains/infra-guide.git
cd infra-guide

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode with dev dependencies
pip install -e ".[dev]"

Running Tests

pytest

Code Formatting

black infra_guide/

Type Checking

mypy infra_guide/

πŸ“ Project Structure

infra-guide/
β”œβ”€β”€ infra_guide/
β”‚   β”œβ”€β”€ __init__.py          # Package initialization
β”‚   β”œβ”€β”€ cli.py               # Main CLI entry point
β”‚   β”œβ”€β”€ detector.py          # Tool detection logic
β”‚   β”œβ”€β”€ ui.py                # UI components using rich
β”‚   β”œβ”€β”€ runner.py            # Command execution
β”‚   └── guides/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ init.py          # Init command guide
β”‚       β”œβ”€β”€ plan.py          # Plan command guide
β”‚       β”œβ”€β”€ apply.py         # Apply command guide
β”‚       └── destroy.py       # Destroy command guide
β”œβ”€β”€ pyproject.toml           # Project configuration
β”œβ”€β”€ README.md                # Documentation
└── LICENSE                  # MIT License

πŸ—ΊοΈ Roadmap

Completed βœ…

βœ…Core IaC commands (init, plan, apply, destroy)
βœ…Drift detection
βœ…Pre-flight validations
βœ…State explorer with tree visualization
βœ…Workspace management
βœ…CI/CD pipeline mode
βœ…Comprehensive error handling

Coming Soon

Policy-as-code integration (OPA, Sentinel)
Cost estimation before apply
Graph visualization of resource dependencies
Plan diff with syntax highlighting
Custom command templates
Configuration file for user preferences
Color theme customization
Command history and favorites
Export reports to markdown/PDF
Integration with popular CI/CD platforms
Multi-language support
Cloud provider-specific guidance
Terraform/OpenTofu module browser

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and formatting
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with Rich for beautiful terminal output
  • Inspired by the need to make Infrastructure as Code more accessible to beginners
  • Thanks to the Terraform and OpenTofu communities

πŸ“ž Support

Made with ❀️ by CloudGrains for the Infrastructure as Code community