Terrateam behavior can be configured via a
config.yml. This file is located in
a directory named
.terrateam at the root of your Terraform repository:
See Configuration documentation for details.
Apply Outside Terrateam
In some cases one might want to propose changes through a Pull Request, for visibility, however apply them locally for compliance reasons. By default, Terrateam requires any change that is merged to be applied inside of Terrateam. To ensure this, a lock is acquired on the changed directory until it is applied.
To support a directory being applied outside of Terrateam, the
option in a workflow supports configuring when a
lock is acquired.
For security reasons, the credentials for making IAM changes are not allowed on
third-party infrastructure. However, for visibility, pull requests are created
for IAM changes. With this workflow, we do not want to acquire a lock on the
IAM directory. The IAM directory is
environments/prod/iam. To prevent a lock
from being acquired:
This configures Terrateam to acquire a lock only if an apply for the directory has been performed in Terrateam. Otherwise, no lock will be acquired.
Autoapply on Merge
Automatically apply Terraform changes after a pull request is merged.
Automatically run Apply after all merge commits:
Automatically run Apply after a merge commit against a pull request
with a When Modified file pattern match in the
Automerge and Delete Branch
Upon successfully applying all changes in a pull request, automatically merge the pull request and delete the branch.
Run a custom command during a Terrateam operation:
- Pre workflow: one time per operation
- Post workflow: one time per operation
- Part of a workflow: one time per workflow in an operation
In the following example:
- Echo statements are written to the console pre and post Plan and Apply operations.
- Environment variables are echoed to the console using the
cmdparameter for Plan and Apply workflow steps that run against each targeted Dirspace in the operation.
$TERRATEAM_DIR: Current working directory for the Dirspace.
$TERRATEAM_WORKSPACE: Workspace that is currently being executed against the Dirspace.
Do not automatically run a Plan operation on changes in a pull request. This is a global setting and can be overriden for specific directories with Dirs.
Do not automatically run a Plan for changes in the
Disable Plan and Apply
The When Modified
configuration is used to determine if a directory has a Terraform change.
If a change exists then Terrateam will trigger an operation against the directory.
In the case of module directories, users usually do not want to run a Terrateam operation. Typically, module directories do not contain underlying Terraform resources. The code found in module directories are usually used as dependencies for other Terraform directories with underlying Terraform resources.
file_patterns configuration for a module directory to an empty list
will instruct Terrateam to not trigger Terrateam operations against the directory.
Changes found in the
modules directory can still be used to trigger Terrateam operations against
other directories that have a dependency on the
See Trigger on Terraform Modules documentation for an example on how to trigger a Terrateam operation based on a modules directory update.
A Gitflow-style workflow can be accomplished with Destination Branches.
The following example will trigger a Terrateam operation when performing a pull
request against any
release branch. It also triggers a Terrateam operation on
pull requests against
main, but only with a
hotfix source branch.
Terraform Modules Directory Dependency
Create a source modules directory dependency that triggers an operation for another directory.
Trigger on Modules Update
Create a directory dependency with the following rules:
- Do not automatically run a Plan operation when the
modulesdirectory is updated.
- Automatically run a Plan operation against the
iamdirectory when the
modulesdirectory is updated.
The following configuration creates a
modules directory dependency for the