
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