github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/cli/run/index.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Provisioning Infrastructure - Terraform CLI" 4 description: "Learn about commands for core provisioning tasks: plan, apply, and destroy." 5 --- 6 7 # Provisioning Infrastructure with Terraform 8 9 Terraform's primary function is to create, modify, and destroy infrastructure 10 resources to match the desired state described in a 11 [Terraform configuration](/docs/language/index.html). 12 13 When people refer to "running Terraform," they generally mean performing these 14 provisioning actions in order to affect real infrastructure objects. The 15 Terraform binary has many other subcommands for a wide variety of administrative 16 actions, but these basic provisioning tasks are the core of Terraform. 17 18 Terraform's provisioning workflow relies on three commands: `plan`, `apply`, and 19 `destroy`. All of these commands require an 20 [initialized](/docs/cli/init/index.html) working directory, and all of them act 21 only upon the currently selected [workspace](/docs/cli/workspaces/index.html). 22 23 ## Planning 24 25 The `terraform plan` command evaluates a Terraform configuration to determine 26 the desired state of all the resources it declares, then compares that desired 27 state to the real infrastructure objects being managed with the current working 28 directory and workspace. It uses state data to determine which real objects 29 correspond to which declared resources, and checks the current state of each 30 resource using the relevant infrastructure provider's API. 31 32 Once it has determined the difference between the current state and the desired 33 state, `terraform plan` presents a description of the changes necessary to 34 achieve the desired state. It _does not_ perform any actual changes to real 35 world infrastructure objects; it only presents a plan for making changes. 36 37 Plans are usually run to validate configuration changes and confirm that the 38 resulting actions are as expected. However, `terraform plan` can also save its 39 plan as a runnable artifact, which `terraform apply` can use to carry out those 40 exact changes. 41 42 For details, see [the `terraform plan` command](/docs/cli/commands/plan.html). 43 44 ## Applying 45 46 The `terraform apply` command performs a plan just like `terraform plan` does, 47 but then actually carries out the planned changes to each resource using the 48 relevant infrastructure provider's API. It asks for confirmation from the user 49 before making any changes, unless it was explicitly told to skip approval. 50 51 By default, `terraform apply` performs a fresh plan right before applying 52 changes, and displays the plan to the user when asking for confirmation. 53 However, it can also accept a plan file produced by `terraform plan` in lieu of 54 running a new plan. You can use this to reliably perform an exact set of 55 pre-approved changes, even if the configuration or the state of the real 56 infrastructure has changed in the minutes since the original plan was created. 57 58 For details, see [the `terraform apply` command](/docs/cli/commands/apply.html). 59 60 ## Destroying 61 62 The `terraform destroy` command destroys all of the resources being managed by 63 the current working directory and workspace, using state data to determine which 64 real world objects correspond to managed resources. Like `terraform apply`, it 65 asks for confirmation before proceeding. 66 67 A destroy behaves exactly like deleting every resource from the configuration 68 and then running an apply, except that it doesn't require editing the 69 configuration. This is more convenient if you intend to provision similar 70 resources at a later date. 71 72 For details, see [the `terraform destroy` command](/docs/cli/commands/destroy.html).