Introduction
When using the CLI-driven workflow in HashiCorp Cloud Platform - Terraform (HCPT) Workspaces in "remote" execution mode, the Terraform configuration located in the directory is archived and uploaded to HCPT. The Cloud worker then starts a run using the uploaded configuration.
Use Case
The configuration directory could contain a number of files that can vary in size.
Depending on the size of your configuration the archive creation and its upload can take more time.
In such case it may appear that the run is stuck at :
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 a few minutes or more depending on the size of the local directory.
Solution
In order to skip the upload of unnecessary files contained in the configuration folder, the .terraformignore
file can be used.
The .terraformignore
file can include rules as one would include in a .gitignore file:
- Comments (starting with
#
) or 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
!
Note that unlike .gitignore
, only the .terraformignore
at the root of the configuration directory is considered.
Ignoring the unnecessary files helps save time for the upload to HCPT.
Note:.terraformignore
support was added in Terraform 0.12.11