github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/commands/apply.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Command: apply" 4 sidebar_current: "docs-commands-apply" 5 description: |- 6 The `terraform apply` command is used to apply the changes required to reach the desired state of the configuration, or the pre-determined set of actions generated by a `terraform plan` execution plan. 7 --- 8 9 # Command: apply 10 11 The `terraform apply` command is used to apply the changes required 12 to reach the desired state of the configuration, or the pre-determined 13 set of actions generated by a `terraform plan` execution plan. 14 15 ## Usage 16 17 Usage: `terraform apply [options] [dir-or-plan]` 18 19 By default, `apply` scans the current directory for the configuration 20 and applies the changes appropriately. However, a path to another configuration 21 or an execution plan can be provided. Explicit execution plans files can be 22 used to split plan and apply into separate steps within 23 [automation systems](https://learn.hashicorp.com/terraform/development/running-terraform-in-automation). 24 25 The command-line flags are all optional. The list of available flags are: 26 27 * `-backup=path` - Path to the backup file. Defaults to `-state-out` with 28 the ".backup" extension. Disabled by setting to "-". 29 30 * `-compact-warnings` - If Terraform produces any warnings that are not 31 accompanied by errors, show them in a more compact form that includes only 32 the summary messages. 33 34 * `-lock=true` - Lock the state file when locking is supported. 35 36 * `-lock-timeout=0s` - Duration to retry a state lock. 37 38 * `-input=true` - Ask for input for variables if not directly set. 39 40 * `-auto-approve` - Skip interactive approval of plan before applying. 41 42 * `-no-color` - Disables output with coloring. 43 44 * `-parallelism=n` - Limit the number of concurrent operation as Terraform 45 [walks the graph](/docs/internals/graph.html#walking-the-graph). Defaults to 46 10. 47 48 * `-refresh=true` - Update the state for each resource prior to planning 49 and applying. This has no effect if a plan file is given directly to 50 apply. 51 52 * `-state=path` - Path to the state file. Defaults to "terraform.tfstate". 53 Ignored when [remote state](/docs/state/remote.html) is used. 54 55 * `-state-out=path` - Path to write updated state file. By default, the 56 `-state` path will be used. Ignored when 57 [remote state](/docs/state/remote.html) is used. 58 59 * `-target=resource` - A [Resource 60 Address](/docs/internals/resource-addressing.html) to target. For more 61 information, see 62 [the targeting docs from `terraform plan`](/docs/commands/plan.html#resource-targeting). 63 64 * `-var 'foo=bar'` - Set a variable in the Terraform configuration. This flag 65 can be set multiple times. Variable values are interpreted as 66 [HCL](/docs/configuration/syntax.html#HCL), so list and map values can be 67 specified via this flag. 68 69 * `-var-file=foo` - Set variables in the Terraform configuration from 70 a [variable file](/docs/configuration/variables.html#variable-files). If 71 a `terraform.tfvars` or any `.auto.tfvars` files are present in the current 72 directory, they will be automatically loaded. `terraform.tfvars` is loaded 73 first and the `.auto.tfvars` files after in alphabetical order. Any files 74 specified by `-var-file` override any values set automatically from files in 75 the working directory. This flag can be used multiple times.