Apply requirements
Apply requirements in Terrateam allow you to define a set of conditions that must be met before an apply operation can be executed on a pull request. These requirements help ensure that changes to your infrastructure are properly reviewed and approved before being applied.
Configuration
Apply Requirements are configured in the .terrateam/config.yml
file under the apply_requirements.checks
key. Here’s the default configuration:
Approved
The approved
key is used to specify whether a certain number of approvals are required on the pull request before an apply operation can be executed.
Key | Type | Description |
---|---|---|
enabled | Boolean | Specifies whether the approval requirement is enabled. Default is false . |
count | Integer | The number of approvals required. Default is 1 . |
Merge conflicts
The merge_conflicts
key is used to specify whether the pull request must have no merge conflicts before an apply operation can be executed.
Key | Type | Description |
---|---|---|
enabled | Boolean | Specifies whether the merge conflict check is enabled. Default is true . |
Status checks
The status_checks
key is used to specify whether all status checks associated with the pull request must pass before an apply operation can be executed.
Key | Type | Description |
---|---|---|
enabled | Boolean | Specifies whether the status checks requirement is enabled. Default is true . |
ignore_matching | List | A list of regular expressions. Status checks matching any of these expressions will be ignored. Default is [] . |
Examples
Require 2 approvals and no merge conflicts
This configuration will require the pull request to have at least 2 approvals and no merge conflicts before an apply operation can be executed.
Require status checks, ignoring certain checks
This configuration will require all status checks associated with the pull request to pass before an apply operation can be executed, except for checks matching the regular expressions "ci/.*"
or "lint"
.
Considerations
When configuring apply requirements, keep the following in mind:
- Apply requirements are evaluated whenever an apply operation is attempted, whether manually or through an autoapply trigger.
- If any of the enabled requirements are not met, the apply operation will not be executed, and an error message will be displayed.
- Apply requirements can be overridden using the
terrateam apply-force
command, which bypasses all requirements. This command should be used with caution and only by authorized users.