Forrest logo
back to the terraform tool

terraform:tldr:d3bb4

terraform: Build or change infrastructure.
$ terraform apply
try on your machine

The terraform apply command is used to apply the changes specified in a Terraform configuration file (usually named main.tf) to the defined infrastructure.

When you run terraform apply, Terraform reads the current state of the infrastructure and the configuration file, then determines the changes that need to be made to reach the desired state specified in the configuration file.

The command will prompt you to confirm the planned changes. If you choose to proceed, Terraform will create, modify, or destroy resources as necessary to match the desired infrastructure specified in the configuration file. It will also update the state file with the new state of the infrastructure.

Here's a high-level overview of the process that occurs when you run terraform apply:

  1. Terraform compares the current state of the infrastructure to the desired state specified in the configuration file.
  2. It determines what actions need to be taken to reach the desired state (e.g., creating new resources, modifying existing ones, or destroying unnecessary resources).
  3. Terraform presents a summary of the planned changes and prompts you to confirm.
  4. If you confirm, Terraform executes the planned changes, communicating with the corresponding APIs of the cloud providers or infrastructure services.
  5. Resources are created, modified, or destroyed, and Terraform tracks the changes made.
  6. Terraform updates the state file to reflect the new state of the infrastructure.

terraform apply is a critical command while working with Terraform, as it applies the actual changes to the infrastructure. It should be used with caution, especially in production environments, as it can lead to unintended consequences if not used carefully.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the terraform tool