Used for initializing working directories, including loading provider, backend, and module blocks. You can run this command repetitively in the same working directory.
tip
Running terraform init -upgrade=true command updates providers and modules.
Used for creating preparatory plans. Before running the terraform apply command, you must run this command to preview the pending changes and verify whether they are as expected. That is, whether the attributes of the cloud resources differ from those in the state file.
tip
By default, this command first updates resource attributes from the remote. When there are many resources, the operation may take a long time. You can execute terraform plan -refresh=false to disable updates.
If Terraform detects differences, it outputs the differences:
If Terraform does not detect any differences, it outputs the following information:
Used for creating or modifying resources. Before executing actions, a human-computer interaction is required to confirm resource creation and modification. You can run terraform apply -auto-approve to skip human-computer interaction and directly execute.
This command saves its running result to the terraform.tfstate file and displays the output variables of resources. Example:
Used for deleting resources. Before executing actions, a human-computer interaction is required to confirm resource deletion. You can run terraform destroy -auto-approve to skip human-computer interaction and directly delete resources.
tip
By default, the terraform destroy command deletes all resources in the current module. Proceed with caution.
To delete a specific resource, use the following format: -target=<RESOURCE_TYPE>.<RESOURCE_NAME>.
Used for refreshing the configurations of the state file. After you run this command, it calls the remote API to obtain the latest data and writes the results to the state file.
Used for displaying all managed resources and their attribute values in the state file.
Used for displaying the output variables in the current configuration. This command outputs the output variables defined in the configuration one by one. The format is OUTPUT_VARIABLE_NAME = OUTPUT_VARIABLE_VALUE.