Problem
When running terraform plan through terraform cloud for a VCS driven workspace, the runs may not be triggered even though you make changes in the VCS Repo as per the trigger pattern set in Workspace Settings.
Background
When configuring version control settings for a terraform cloud workspace, we need to define the Terraform Working Directory
in the Workspace settings. If the value of Terraform Working Directory
is left blank, terraform may by default execute on the basis of files located at the root folder.
For example - Let's say we have a VCS repo called VCS Repo
and within that we have two folders called Test
and Prod
. If we need to execute the terraform (.tf) files only located inside the Test
folder and not in the Prod
folder, we need to define the Terraform Working Directory
as Test
so that only the files from within Test
folder are executed.
We also have a requirement that only changes in .tf
files within the folder Test
, should trigger the run.
Issue
We have the following settings:
- We have updated the
Terraform Working Directory
asTest
. - In the
VCS Triggers
section of theWorkspace Settings
>>Version Control
, we have selectedOnly trigger runs when files in specified paths change
and put the pattern as/Test/*.tf
.
Whenever, we make some changes in .tf files
within the folder Test
, the runs are not triggered intermittently.
Solution:
In the section Only trigger runs when files in specified paths change
make sure you have put the pattern as /Test/**/*.tf
so that all the files with an extension .tf
within the folder Test
are considered for triggering the run.
Outcome
If we want the trigger to take place for all the files with a specific file extension (.tf in this case) within a specific folder of the repo, we need to make sure to put double asterisk (**)
before the file extension in the section Only trigger runs when files in specified paths change