CloudGrains logo
Back to infra-guide

infra-guide v0.2.0 Documentation

Production-grade interactive tool with enterprise features - Complete installation and usage guide

MIT LicensePython 3.8+Version 0.2.0

Overview

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

πŸ“‹ 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 git+https://github.com/cloudgrains-git/infra-guide.git

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-git/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 PyPI (when published)

pipx install infra-guide

Coming Soon: This option will be available once the package is published to PyPI.

πŸ“– 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)
  • Review the guide
  • Confirm execution

2. Validate configuration

  • Select option 5 (validate)
  • Run pre-flight checks
  • Fix any issues found

3. Preview changes

  • Select option 2 (plan)
  • Review the guide and understand what will change
  • Confirm execution

4. Apply changes

  • Select option 3 (apply)
  • Read warnings carefully
  • Confirm execution

Advanced Workflow:

1. Check for drift

  • Select option 6 (drift)
  • Detect changes made outside Terraform
  • Review drift report

2. Explore state

  • Select option 7 (state)
  • Browse current infrastructure
  • View resource tree and statistics

3. Manage environments

  • Select option 8 (workspace)
  • Switch between dev/staging/prod
  • Create or delete workspaces

4. Run CI/CD pipeline

  • Select option 9 (cicd)
  • Automated validation and planning
  • No user interaction required

🎯 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-git/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