Plan and Apply
The Plan and Apply operations are the core of Terrateam’s functionality. They allow you to preview and execute changes to your infrastructure in a controlled and collaborative manner.
Plan
The Plan operation generates a preview of changes that will be made to your infrastructure when you apply your Terraform code. This preview is called a “plan” in Terraform terminology.
The following example shows a common usage of the plan feature, enabling you to review changes and collaborate with your team before the changes are applied:
-
Open a pull request with changes to your Terraform code.
-
Terrateam automatically triggers a Plan operation.
-
Review the plan output in the PR comment. It shows what will be created, modified, or destroyed:
You can manually trigger another Plan by commenting terrateam plan
on the pull request.
Apply
The Apply operation executes the changes previewed in the Plan. This is when actual infrastructure changes occur. Here’s an example of a common usage of the apply feature:
-
Ensure your pull request has a successful Plan operation.
-
Comment
terrateam apply
on the pull request. -
Terrateam acquires a lock on the affected directories to prevent conflicting changes.
-
Terrateam runs the Apply operation:
-
Verify the apply was successful by reviewing the output.
-
Merge the pull request to complete your workflow.
-
Terrateam automatically releases the lock.
Apply Requirements
Terrateam has a set of Apply Requirements that must be met before an Apply operation can be triggered. These include:
- Requiring a certain number of approvals on the pull request.
- Ensuring there are no merge conflicts.
- Checking that all status checks have passed.
You can configure these requirements in your Terrateam configuration file.
Auto-Apply
If you want to automatically apply changes when a pull request is merged, you can use the When Modified feature.
when_modified: autoapply: true
Apply Before Merge vs. After Merge
Terrateam supports two main approaches based on when infrastructure changes are applied, either before or after a pull request is merged. This flexibility lets you match your deployment process to your team’s needs.
Terrateam lets you define the sequence of steps during Plan and Apply. You can customize these steps to enforce approvals, manage concurrency, or trigger applies at the right time.
If you want to validate and apply changes before merging, you can use a pre-merge approach combined with automerge to apply changes automatically once checks pass.