tofu-plan
Plan infrastructure changes
TLDR
Generate and show the execution plan in the currently directory
Show a plan to destroy all remote objects that currently exist
Show a plan to update the Tofu state and output values
Specify values for input variables
Focus Tofu's attention on only a subset of resources
Output a plan as JSON
Write a plan to a specific file
SYNOPSIS
tofu plan [options]
PARAMETERS
-destroy
Generate a plan to destroy all managed infrastructure.
-detailed-exitcode
Return a non-zero exit code if the plan resulted in changes.
-generate-missing-vars
Ask for values for missing variables, even if a default value is defined.
-input=
Ask for input for variables if not directly set. Defaults to true.
-lock=
Lock the state file during the operation. Defaults to true.
-lock-timeout=
Duration to wait for a state lock. Defaults to '0s' (no timeout).
-no-color
Disable colored output.
-out=
Write the plan to the given file.
-parallelism=
Limit the number of concurrent operations. Defaults to 10.
-refresh=
Update state prior to planning. Defaults to true.
-state=
Path to the state file. Defaults to 'terraform.tfstate'.
-var
Set a variable in the Terraform configuration.
-var-file=
Load variables from the given file.
DESCRIPTION
The `tofu-plan` command, typically used within a Terraform workflow, allows you to preview the changes Terraform will make to your infrastructure without actually applying those changes. It reads the Terraform configuration files in your current directory and compares the desired state defined in the configuration with the actual state of your infrastructure (as stored in the Terraform state file). The command then generates a plan that outlines the proposed additions, modifications, and deletions of resources.
The plan output is detailed, showing the attributes of each resource that will be affected. Reviewing the plan allows you to verify that the changes are what you expect and catch any potential errors or unintended consequences before they are implemented.
A plan can be saved to a file and applied later using the `tofu-apply` command, ensuring that the same changes are applied consistently. Using `tofu-plan` is a crucial step in infrastructure as code, promoting safe and predictable deployments.
PLAN OUTPUT INTERPRETATION
The plan output will show resources that are being added (+), changed (~), or destroyed (-). Understanding these symbols is essential for correctly interpreting the plan. Changes marked with a '~' may include in-place updates or replacements, depending on the resource type and attribute being modified. Replacements will first destroy the existing resource and then create the new one. Always review the details of a change to understand its impact.
SEE ALSO
tofu-apply(1), tofu-destroy(1), tofu-state(1)