← 返回命令列表

Linux command

tofu 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Initialize directory

tofu init

Plan changes

tofu plan

Apply changes

tofu apply

Destroy resources

tofu destroy

Format files

tofu fmt

Validate config

tofu validate

说明

tofu (OpenTofu) is an open-source infrastructure-as-code tool forked from Terraform, allowing you to define cloud and on-premises resources in declarative HCL configuration files. It supports major cloud providers including AWS, GCP, and Azure through a provider plugin system. The workflow follows an init-plan-apply cycle: init downloads providers and modules, plan previews proposed changes, and apply creates or modifies the actual infrastructure. State is tracked in a state file that maps configuration to real resources, enabling incremental updates and safe destruction with destroy.

参数

init
Initialize working directory.
plan
Show execution plan.
apply
Apply changes.
destroy
Remove resources.
fmt
Format files.
validate
Check configuration.
-auto-approve
Skip approval.

FAQ

What is the tofu command used for?

tofu (OpenTofu) is an open-source infrastructure-as-code tool forked from Terraform, allowing you to define cloud and on-premises resources in declarative HCL configuration files. It supports major cloud providers including AWS, GCP, and Azure through a provider plugin system. The workflow follows an init-plan-apply cycle: init downloads providers and modules, plan previews proposed changes, and apply creates or modifies the actual infrastructure. State is tracked in a state file that maps configuration to real resources, enabling incremental updates and safe destruction with destroy.

How do I run a basic tofu example?

Run `tofu init` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does init do in tofu?

Initialize working directory.