terraform-step-debug

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2025 License: MIT

README ΒΆ

πŸ” Terraform Step Debugger

Go Report Card License Go Version

A CLI tool that intercepts Terraform apply operations and executes them step-by-step with user approval for each resource operation, similar to a code debugger.

✨ Features

  • πŸ“‹ Generate a Terraform plan
  • πŸ”Ž Parse the plan to identify individual resource operations
  • πŸ‘οΈ Present each operation to the user for review/approval
  • πŸš€ Execute operations one-by-one using targeted apply
  • πŸ›‘ Allow stepping, skipping, or aborting the process
  • 🧩 Dependency-aware execution order
  • πŸ”„ Support for variable files (tfvars)

⚠️ Disclaimer

USE AT YOUR OWN RISK. This tool is provided "as is", without warranty of any kind, express or implied. Neither the authors nor contributors shall be liable for any damages or consequences arising from the use of this tool. Always:

  • πŸ§ͺ Test in a non-production environment first
  • βœ“ Verify results manually before taking action
  • πŸ’Ύ Maintain proper backups
  • πŸ”’ Follow your organization's security policies

πŸ“₯ Installation

From Source
# Clone the repository
git clone https://github.com/marc-poljak/terraform-step-debug.git
cd terraform-step-debug

# Build and install
make install
Using Go
go install github.com/marc-poljak/terraform-step-debug/cmd/terraform-step-debug@latest

πŸš€ Usage

# Basic usage (in a Terraform directory)
terraform-step-debug

# Specify a Terraform directory
terraform-step-debug --dir /path/to/terraform/project

# Use an existing plan file
terraform-step-debug --plan /path/to/terraform.tfplan

# Use with a variable file (e.g., prod.tfvars)
terraform-step-debug --var-file prod.tfvars

# Dry run mode (don't apply changes)
terraform-step-debug --dry-run

# Target a specific resource
terraform-step-debug --target aws_instance.example
🌐 Environment-Specific Deployments

For different environments, you can use variable files:

# Development environment
terraform-step-debug

# Staging environment
terraform-step-debug --var-file staging.tfvars

# Production environment 
terraform-step-debug --var-file prod.tfvars

This ensures that all operations use the correct variable values for each environment, maintaining consistency between planning and execution.

⌨️ Commands During Execution

During the step-by-step execution, you can use the following commands:

  • a or apply - Apply the current resource
  • s or skip - Skip the current resource
  • d or detail - Show detailed information about the current resource
  • x or abort - Abort the execution

πŸ§ͺ Example

The repository includes a local demo in examples/local-demo that you can use to try the tool without requiring any cloud provider access:

cd examples/local-demo
terraform init
terraform-step-debug --var-file prod.tfvars

The demo includes different variable files for development, staging, and production environments, showing how the tool can be used with environment-specific configurations.

πŸ“‹ Requirements

  • Go 1.21 or higher
  • Terraform 0.12 or higher

πŸ› οΈ Development

# Clone the repository
git clone https://github.com/marc-poljak/terraform-step-debug.git
cd terraform-step-debug

# Run tests
make test

# Run linter
make lint

# Build the binary
make build

# Build and run
make run

πŸ“ Project Structure

terraform-step-debug/
β”œβ”€β”€ cmd/
β”‚   └── terraform-step-debug/    # Main command entrypoint
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ executor/                # Apply step execution
β”‚   β”œβ”€β”€ parser/                  # Terraform plan parsing
β”‚   β”œβ”€β”€ model/                   # Data structures
β”‚   β”œβ”€β”€ ui/                      # Interactive UI components
β”‚   └── util/                    # Helper functions
β”œβ”€β”€ examples/
β”‚   └── local-demo/              # Local demo with variable files
β”œβ”€β”€ build/                       # Build artifacts
β”œβ”€β”€ go.mod
β”œβ”€β”€ go.sum
β”œβ”€β”€ LICENSE
β”œβ”€β”€ Makefile
└── README.md

πŸ‘₯ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“œ License

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

πŸ‘ Acknowledgments

  • Created with assistance from Claude by Anthropic
  • Inspired by the need for step-by-step control of Terraform execution

Directories ΒΆ

Path Synopsis
cmd
internal
ui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL