OpenTofu wrapper for interactive apply sessions
README.md

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:

  1. Run tofu apply to generate a plan
  2. Show the interactive review UI
  3. Wait for your approval or rejection
  4. Send your decision to OpenTofu
  5. Display the apply results

Interactive UI Controls #

Once in the interactive review:

  • j or ↓ - Navigate to next resource
  • k or ↑ - Navigate to previous resource
  • Space - Toggle reviewed status for current resource
  • Enter - Expand/collapse resource details
  • A - Approve and apply (available once all resources are reviewed)
  • R or q or Esc - 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 #

  1. Plan generation: tfapply runs tofu apply and captures the plan output
  2. Plan parsing: The output is parsed to extract individual resource changes
  3. Interactive review: A terminal UI is launched showing all resources
  4. Decision: User navigates and reviews resources, then approves or rejects
  5. 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.

  • tfapply.nvim - Neovim plugin for interactive OpenTofu apply