Skip to content

Automation with OpenTofu

OpenTofu Features

Backend for state and lock

The backend defines where OpenTofu stores its state data files. And some of the backend types support locking of the state file as well to avoid multiple process (or multiple people) making changes to the state file at the same time. Available backends are listed on the OpenTofu documentation

OpenTofu CLI

Some of the most used tofu commands are listed below.

Init

tofu init

Plan

tofu plan

To save the output of the plan command:

tofu plan -out tfplan

Apply

tofu apply

For auto approval:

tofu apply -auto-approve

If the outplan of the plan command was previously saved, it can be passed to the apply command:

tofu apply tfplan

Destroy

To destroy/remove all the provisioned resources:

tofu destroy