- Go 100%
tfapply #
Interactive OpenTofu apply CLI with resource-by-resource review.
Overview #
tfapply is a command-line tool that enhances the OpenTofu apply workflow by providing an interactive terminal UI for reviewing changes before they are applied. Instead of reviewing the entire plan at once and making a single approve/reject decision, you can:
- Navigate through each resource that will be changed
- Review detailed changes for individual resources
- Mark resources as reviewed as you go
- Approve or reject the entire plan after review
This provides a more thoughtful and controlled approach to infrastructure changes, reducing the risk of accidentally applying unwanted changes.
Features #
- Interactive TUI: Terminal-based user interface with keyboard navigation
- Resource-by-resource review: Navigate through each resource change individually
- Visual indicators: Color-coded action types (create, update, destroy, replace)
- Progress tracking: See how many resources you've reviewed
- Flexible configuration: Optional flags to customize behavior
Installation #
From source #
git clone https://tangled.org/mariuskimmina/tfapply
cd tfapply
just build
just install
Using go install #
go install tangled.org/mariuskimmina/tfapply@latest
Usage #
Basic usage #
Simply run tfapply in a directory with OpenTofu configuration:
tfapply
This will:
- Run
tofu applyto generate a plan - Show the interactive review UI
- Wait for your approval or rejection
- Send your decision to OpenTofu
- Display the apply results
Interactive UI Controls #
Once in the interactive review:
jor↓- Navigate to next resourcekor↑- Navigate to previous resourceSpace- Toggle reviewed status for current resourceEnter- Expand/collapse resource detailsA- Approve and apply (available once all resources are reviewed)RorqorEsc- Reject and cancel
Command-line flags #
# Allow approval without reviewing all resources
tfapply --require-review-all=false
# Show unchanged attributes in resource details
tfapply --show-unchanged
# Target specific resources
tfapply -t aws_instance.web -t aws_security_group.web_sg
Common workflows #
Review and apply all changes #
tfapply
# Navigate through resources with j/k
# Press Space to mark each as reviewed
# Press A to approve once all are reviewed
Apply specific resources only #
tfapply -t aws_instance.web
Configuration #
Flags #
| Flag | Default | Description |
|---|---|---|
--require-review-all |
true |
Require all resources to be reviewed before approving |
--show-unchanged |
false |
Show unchanged attributes in resource details |
-t, --target |
[] |
Resource to target (can be specified multiple times) |
How it works #
- Plan generation:
tfapplyrunstofu applyand captures the plan output - Plan parsing: The output is parsed to extract individual resource changes
- Interactive review: A terminal UI is launched showing all resources
- Decision: User navigates and reviews resources, then approves or rejects
- Apply: The decision is sent to OpenTofu, which continues or aborts accordingly
Why tfapply? #
Traditional OpenTofu workflow shows you the entire plan and asks for a single yes/no decision. For large infrastructure changes with many resources, it's easy to:
- Miss important changes in the wall of text
- Accidentally approve destructive changes
- Feel rushed to make a decision
tfapply solves this by letting you:
- Review changes at your own pace
- Focus on one resource at a time
- Track which resources you've reviewed
- Make a more informed decision
Neovim Integration #
tfapply is designed to work standalone, but it also integrates seamlessly with the tfapply.nvim plugin. The Neovim plugin can be configured to use this CLI as a backend, providing the same interactive experience within your editor.
Requirements #
- OpenTofu installed and available in PATH as
tofu - Go 1.21 or later (for building from source)
- just command runner (for building with justfile)
License #
MIT
Contributing #
Contributions are welcome! Please feel free to submit issues or pull requests.
Related Projects #
- tfapply.nvim - Neovim plugin for interactive OpenTofu apply