2014-07-25 00:53:46 +02:00
---
layout: "docs"
page_title: "Command: apply"
sidebar_current: "docs-commands-apply"
2014-10-22 05:21:56 +02:00
description: |-
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.
2014-07-25 00:53:46 +02:00
---
# Command: apply
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.
## Usage
2015-06-17 17:10:23 +02:00
Usage: `terraform apply [options] [dir-or-plan]`
2014-07-25 00:53:46 +02:00
By default, `apply` scans the current directory for the configuration
and applies the changes appropriately. However, a path to another configuration
or an execution plan can be provided. Execution plans can be used to only
execute a pre-determined set of actions.
2014-09-30 00:58:45 +02:00
The `dir` argument can also be a [module source ](/docs/modules/index.html ).
In this case, `apply` behaves as though `init` were called with that
argument followed by an `apply` in the current directory. This is meant
as a shortcut for getting started.
2014-07-25 00:53:46 +02:00
The command-line flags are all optional. The list of available flags are:
2014-07-28 05:40:18 +02:00
* `-backup=path` - Path to the backup file. Defaults to `-state-out` with
2014-08-07 09:19:56 +02:00
the ".backup" extension. Disabled by setting to "-".
2014-07-28 05:40:18 +02:00
2014-12-06 00:39:49 +01:00
* `-input=true` - Ask for input for variables if not directly set.
2014-07-25 00:53:46 +02:00
* `-no-color` - Disables output with coloring.
2015-10-06 00:18:03 +02:00
* `-parallelism=n` - Limit the number of concurrent operation as Terraform
[walks the graph ](/docs/internals/graph.html#walking-the-graph ).
2014-07-27 02:50:53 +02:00
* `-refresh=true` - Update the state for each resource prior to planning
and applying. This has no effect if a plan file is given directly to
apply.
2014-07-25 00:53:46 +02:00
* `-state=path` - Path to the state file. Defaults to "terraform.tfstate".
2016-08-08 02:59:28 +02:00
Ignored when [remote state ](/docs/state/remote/index.html ) is used.
2014-07-25 00:53:46 +02:00
* `-state-out=path` - Path to write updated state file. By default, the
2016-08-08 02:59:28 +02:00
`-state` path will be used. Ignored when
[remote state ](/docs/state/remote/index.html ) is used.
2014-07-25 00:53:46 +02:00
2015-04-01 01:48:54 +02:00
* `-target=resource` - A [Resource
Address](/docs/internals/resource-addressing.html) to target. Operation will
be limited to this resource and its dependencies. This flag can be used
multiple times.
2015-03-27 23:24:15 +01:00
2016-07-12 00:37:51 +02:00
* `-var 'foo=bar'` - Set a variable in the Terraform configuration. This flag
can be set multiple times. Variable values are interpreted as
[HCL ](/docs/configuration/syntax.html#HCL ), so list and map values can be
specified via this flag.
2014-07-25 00:53:46 +02:00
* `-var-file=foo` - Set variables in the Terraform configuration from
2016-07-12 00:37:51 +02:00
a [variable file ](/docs/configuration/variables.html#variable-files ). If
"terraform.tfvars" is present, it will be automatically loaded first. Any
files specified by `-var-file` override any values in a "terraform.tfvars".
This flag can be used multiple times.