#terraform #workspace #cli #tui

app tfocus

Terminal UI for Terraform workspace management

1 unstable release

new 0.1.0 Dec 2, 2024

#5 in #terraform

MIT license

235KB
928 lines

๐ŸŽฏ tfocus

โš ๏ธ WARNING: Resource targeting should be avoided unless absolutely necessary!

What's this? ๐Ÿค”

tfocus is a super interactive tool for selecting and executing Terraform plan/apply on specific resources. Think of it as an "emergency tool" - not for everyday use.

tfocus demo

Features ๐ŸŒŸ

  • ๐Ÿ” Peco-like fuzzy finder for Terraform resources
  • โšก Lightning-fast resource selection
  • ๐ŸŽจ Colorful TUI (Terminal User Interface)
  • ๐ŸŽน Vim-like keybindings
  • ๐Ÿ“ Recursive file scanning

Installation ๐Ÿ› ๏ธ

cargo install --git https://github.com/nwiizo/tfocus

Usage ๐ŸŽฎ

cd your-terraform-project
tfocus
  1. ๐Ÿ” Launch the fuzzy-search UI
  2. โŒจ๏ธ Select resources using vim-like keybindings
  3. ๐ŸŽฏ Execute plan/apply on selected resources

Keybindings ๐ŸŽน

  • โ†‘/k: Move up
  • โ†“/j: Move down
  • /: Incremental search
  • Enter: Select
  • Esc/Ctrl+C: Cancel

โš ๏ธ Important Warning โš ๏ธ

Using terraform resource targeting comes with significant risks:

  1. Potential disruption of the Terraform resource graph
  2. ๐ŸŽฒ Risk of state inconsistencies
  3. ๐Ÿงฉ Possible oversight of critical dependencies
  4. ๐Ÿค– Deviation from standard Terraform workflow

When to Use ๐ŸŽฏ

Only use this tool in specific circumstances:

  • ๐Ÿš‘ Emergency troubleshooting
  • ๐Ÿ”ง Development debugging
  • ๐Ÿงช Testing environment verification
  • ๐Ÿ“Š Impact assessment of large-scale changes

For regular operations, always use full terraform plan and apply!

Appropriate Use Cases ๐ŸŽญ

You might consider using tfocus when:

  • ๐Ÿ”ฅ Working with large Terraform codebases where you need to verify specific changes
  • ๐ŸŒ Full plan execution takes too long during development
  • ๐Ÿ” Emergency inspection of specific resource states
  • ๐Ÿ’ฃ Staged application of changes in complex infrastructure

Remember! Standard terraform plan and apply are the best practices for normal operations.

Development Status ๐Ÿšง

This is an experimental tool. Use at your own risk!

Example ๐Ÿ“บ

$ tfocus
QUERY>

โ–ถ    1 [File]     main.tf
     2 [Module]   vpc
     3 [Resource] aws_vpc.main

[โ†‘/k]Up [โ†“/j]Down [Enter]Select [Esc/Ctrl+C]Cancel

Contributing ๐Ÿค

Issues and PRs are welcome! Please help make this tool safer and more useful.

License ๐Ÿ“œ

MIT

Final Note ๐ŸŽฌ

Think of this tool as a "fire exit" - It's there when you need it, but you hope you never have to use it! ๐Ÿ˜…


made with ๐Ÿฆ€ and โค๏ธ by nwiizo

Dependencies

~7โ€“46MB
~714K SLoC