OpenTofu Open-source infrastructure as code
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
tofu inittofu fmttofu validatetofu plan -out=<file>
tofu apply <file>
tofu outputtofu state listtofu destroyConcepts
- Config .tf files
- Working dir providers, modules
- Plan diff vs. state
- Infrastructure state updated
Workflow
tofu inittofu init -upgrade
tofu init -reconfigure
tofu init -migrate-state
tofu validatetofu plantofu plan -out=<file>
tofu applytofu apply <planfile>
tofu apply -auto-approve
tofu destroytofu plan -destroy
tofu plan -refresh-only
tofu fmttofu fmt -recursive -check
Targeting & plans
tofu plan -target=<addr>
tofu plan -exclude=<addr>
tofu apply -replace=<addr>
tofu plan -refresh=false
tofu plan -parallelism=<n>
tofu plan -detailed-exitcode
tofu plan -generate-config-out=<file>
tofu show <planfile>
tofu show -json <planfile>
tofu graphVariables & outputs
tofu plan -var '<name>=<value>'
tofu plan -var-file=<file>
TF_VAR_<name>=<value>
terraform.tfvars
tofu outputtofu output <name>
tofu output -raw <name>
tofu output -json
tofu consoleState
tofu state listtofu state show <addr>
tofu state mv <src> <dst>
tofu state rm <addr>
tofu state pulltofu state push <file>
tofu import <addr> <id>
tofu taint <addr>
tofu untaint <addr>
tofu force-unlock <id>
tofu refreshWorkspaces
tofu workspace list
tofu workspace show
tofu workspace new <name>
tofu workspace select <name>
tofu workspace delete <name>
Testing & modules
tofu testtofu test -filter=<file>
tofu test -verbose
tofu test -test-directory=<dir>
tofu providerstofu gettofu metadata functions -json
tofu logintofu versiontofu -chdir=<dir> <cmd>
Recipes
tofu inittofu fmt -check && tofu validatetofu plan -out=tfplantofu show tfplantofu apply tfplan
tofu workspace select prodtofu plan -var-file=prod.tfvars -out=prod.plantofu apply prod.plan
tofu state mv aws_instance.old aws_instance.newtofu plan # expect no changes
tofu plan -replace=aws_instance.web -out=fix.plantofu apply fix.plan



