github.com/jzbruno/terraform@v0.10.3-0.20180104230435-18975d727047/website/docs/commands/push.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Command: push" 4 sidebar_current: "docs-commands-push" 5 description: |- 6 The `terraform push` command is used to upload the Terraform configuration to HashiCorp's Terraform Enterprise service for automatically managing your infrastructure in the cloud. 7 --- 8 9 # Command: push 10 11 The `terraform push` command uploads your Terraform configuration to 12 be managed by HashiCorp's [Terraform Enterprise](https://www.hashicorp.com/products/terraform/). 13 By uploading your configuration to Terraform Enterprise, you can automatically run 14 Terraform for you, will save all state transitions, will save plans, 15 and will keep a history of all Terraform runs. 16 17 This makes it significantly easier to use Terraform as a team: team 18 members modify the Terraform configurations locally and continue to 19 use normal version control. When the Terraform configurations are ready 20 to be run, they are pushed to Terraform Enterprise, and any member of your team can 21 run Terraform with the push of a button. 22 23 Terraform Enterprise can also be used to set ACLs on who can run Terraform, and a 24 future update of Terraform Enterprise will allow parallel Terraform runs and automatically 25 perform infrastructure locking so only one run is modifying the same 26 infrastructure at a time. 27 28 ~> When using this command, it is important to match your local Terraform version with 29 the version selected for the target workspace in Terraform Enterprise, since 30 otherwise the uploaded configuration archive may not be compatible with the remote 31 Terraform process. 32 33 ## Usage 34 35 Usage: `terraform push [options] [path]` 36 37 The `path` argument is the same as for the 38 [apply](/docs/commands/apply.html) command. 39 40 The command-line flags are all optional. The list of available flags are: 41 42 * `-atlas-address=<url>` - An alternate address to an instance. 43 Defaults to `https://atlas.hashicorp.com`. 44 45 * `-upload-modules=true` - If true (default), then the 46 [modules](/docs/modules/index.html) 47 being used are all locked at their current checkout and uploaded 48 completely. This prevents Terraform Enterprise from running `terraform get` 49 for you. 50 51 * `-name=<name>` - Name of the infrastructure configuration in Terraform Enterprise. 52 The format of this is: "username/name" so that you can upload 53 configurations not just to your account but to other accounts and 54 organizations. This setting can also be set in the configuration 55 in the 56 [Terraform Enterprise section](/docs/configuration/terraform-enterprise.html). 57 58 * `-no-color` - Disables output with coloring 59 60 61 * `-overwrite=foo` - Marks a specific variable to be updated. 62 Normally, if a variable is already set Terraform will not 63 send the local value (even if it is different). This forces it to 64 send the local value to Terraform Enterprise. This flag can be repeated multiple times. 65 66 * `-token=<token>` - Terraform Enterprise API token to use to authorize the upload. 67 If blank or unspecified, the `ATLAS_TOKEN` environment variable 68 will be used. 69 70 * `-var='foo=bar'` - Set the value of a variable for the Terraform configuration. 71 72 * `-var-file=foo` - Set the value of variables using a variable file. This flag 73 can be used multiple times. 74 75 76 * `-vcs=true` - If true (default), then Terraform will detect if a VCS 77 is in use, such as Git, and will only upload files that are committed to 78 version control. If no version control system is detected, Terraform will 79 upload all files in `path` (parameter to the command). 80 81 ## Packaged Files 82 83 The files that are uploaded and packaged with a `push` are all the 84 files in the `path` given as the parameter to the command, recursively. 85 By default (unless `-vcs=false` is specified), Terraform will automatically 86 detect when a VCS such as Git is being used, and in that case will only 87 upload the files that are committed. Because of this built-in intelligence, 88 you don't have to worry about excluding folders such as ".git" or ".hg" usually. 89 90 If Terraform doesn't detect a VCS, it will upload all files. 91 92 The reason Terraform uploads all of these files is because Terraform 93 cannot know what is and isn't being used for provisioning, so it uploads 94 all the files to be safe. To exclude certain files, specify the `-exclude` 95 flag when pushing, or specify the `exclude` parameter in the 96 [Terraform Enterprise configuration section](/docs/configuration/terraform-enterprise.html). 97 98 Terraform also includes in the package all of the modules that were installed 99 during the most recent `terraform init` or `terraform get` command. Since the 100 details of how modules are cached in the filesystem vary between Terraform versions, 101 it is important to use the same version of Terraform both locally (when running 102 `terraform init` and then `terraform push`) and in your remote Terraform Enterprise 103 workspace. 104 105 ## Terraform Variables 106 107 When you `push`, Terraform will automatically set the local values of 108 your Terraform variables on Terraform Enterprise. The values are only set if they 109 don't already exist. If you want to force push a certain 110 variable value to update it, use the `-overwrite` flag. 111 112 All the variable values stored are encrypted and secured 113 using [Vault](https://www.vaultproject.io). We blogged about the 114 [architecture of our secure storage system](https://www.hashicorp.com/blog/how-atlas-uses-vault-for-managing-secrets.html) if you want more detail. 115 116 The variable values can be updated using the `-overwrite` flag or via 117 the [Terraform Enterprise website](https://www.hashicorp.com/products/terraform/). An example of updating 118 just a single variable `foo` is shown below: 119 120 ```shell 121 $ terraform push -var 'foo=bar' -overwrite foo 122 ``` 123 124 Both the `-var` and `-overwrite` flag are required. The `-var` flag 125 sets the value locally (the exact same process as commands such as apply 126 or plan), and the `-overwrite` flag tells the push command to update Terraform Enterprise. 127 128 ## Remote State Requirement 129 130 `terraform push` requires that 131 [remote state](/docs/state/remote.html) 132 is enabled. The reasoning for this is simple: `terraform push` sends your 133 configuration to be managed remotely. For it to keep the state in sync 134 and for you to be able to easily access that state, remote state must 135 be enabled instead of juggling local files. 136 137 While `terraform push` sends your configuration to be managed by Terraform Enterprise, 138 the remote state backend _does not_ have to be Terraform Enterprise. It can be anything 139 as long as it is accessible by the public internet, since Terraform Enterprise will need 140 to be able to communicate to it. 141 142 **Warning:** The credentials for accessing the remote state will be 143 sent up to Terraform Enterprise as well. Therefore, we recommend you use access keys 144 that are restricted if possible.