Configuration
The Terrateam configuration file (config.yml
) is the primary way to customize how Terrateam interacts with your GitHub repository and Terraform code. This file is stored in the .terrateam
directory at the root of your repository.
Basic Structure
The config.yml
file is written in YAML and has the following basic structure:
Access Control
Access Control allows you to define policies for who can perform various Terrateam operations, such as planning and applying changes. You can configure access based on individual users, GitHub teams, or repository collaborator roles.
Here’s an example access_control
configuration:
This configuration allows anyone to trigger a Plan operation but restricts Apply operations to members of the sre
team.
For more information, see the Access Control section of the Configuration Reference.
Apply Requirements
Apply Requirements allows you to specify conditions that must be met before an Apply operation can be performed on an unmerged pull request. This helps ensure that changes are properly reviewed and validated before being applied.
Here’s an example apply_requirements
configuration:
This configuration requires that the pull request has at least 2 approvals, no merge conflicts, and all status checks (except those matching ci/.*
) have passed before an apply can be performed.
When create_pending_apply_check
is enabled, Terrateam will create a Terrateam Apply
GitHub status check. Combined with GitHub Rulesets, this prevents the pull request from being merged until all Apply operations have completed.
For more information, see the Apply Requirements section of the Configuration Reference.
Dirs
Dirs allow you to define which Tags, Workspaces, and When Modified rules rules apply to specific directories in your repository.
Here’s an example dirs
configuration:
This configuration assigns the Tags aws
and ec2
to the ec2
directory, and the Tags aws
and iam
to the iam
directory. It also specifies that the production
Workspace should be used when a Tag Query includes aws
, ec2
, and production
for a Workflow or Command. Additionally, it overrides the when_modified
file patterns for the ec2
directory.
Terrateam also supports glob patterns in the dirs
directive, allowing you to match multiple directories with similar configurations. The ${DIR}
variable can be used to specify the directory that Terrateam is working against, relative to the root of the repository.
For more information, see the Dirs section of the Configuration Reference.
Hooks
Hooks allow you to run custom commands or set environment variables before (pre-hooks) or after (post-hooks) Terrateam operations. There are three types of Hooks:
all
: Executed for both Plan and Apply operationsplan
: Executed only for Plan operationsapply
: Executed only for Apply operations
Here’s an example hooks
configuration:
For more details, see the Hooks section of the Configuration Reference.
Workflows
Workflows allow you to define custom steps for Terrateam’s Plan and Apply operations. You can use Workflows to replace or augment the default behavior.
Here’s an example workflows
configuration:
This workflow runs a custom plan and apply process for any changes in the production
directory.
For more information, see the Workflows section of the Configuration Reference.
Other Configuration Options
The config.yml
file supports many other configuration options, including:
engine
: Set the IaC tool to be used for operations.when_modified
: Configure when Terrateam should trigger based on file changescost_estimation
: Enable and configure cost estimation for Terraform plansautomerge
: Automatically merge pull requests after successful applies
For a complete list of available options and their usage, refer to the Configuration Reference section of the documentation.