Introduction
When you use the CLI-driven workflow with HCP Terraform workspaces in remote execution mode, Terraform archives the configuration directory and uploads it to HCP Terraform. A cloud agent then starts a run using the uploaded configuration.
Problem
If your configuration directory contains large or numerous files not required for provisioning, the archiving and uploading process can be slow. This may cause the run to appear stuck while preparing the remote plan.
Running plan in the remote backend. Output will stream here. Pressing Ctrl-C will stop streaming the logs, but will not stop the plan running remotely. Preparing the remote plan...
Starting a plan may take several minutes depending on the size of the local directory.
Procedure
To reduce upload times, you can exclude unnecessary files and directories by creating a .terraformignore file in the root of your configuration directory.
Terraform processes this file when creating the configuration archive. The syntax for the .terraformignore file follows the same rules as a .gitignore file.
Key rules include:
- Comments begin with
#and blank lines are ignored. - End a pattern with a forward slash (
/) to specify a directory. - Negate a pattern by starting it with an exclamation point (
!).
Unlike .gitignore, Terraform only considers the .terraformignore file located at the root of the configuration directory.
For example, to ignore all .log files and the temp directory, create a .terraformignore file with the following content:
## Ignore all log files *.log ## Ignore the temp directory temp/
Additional Information
Support for the .terraformignore file was added in Terraform version 0.12.11.