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 is a read-only operation that generates a plan file of the changes that Terraform will make to your infrastructure. When a pull request is opened or updated with changes to Terraform code, Terrateam automatically triggers a Plan operation.
-
Open a pull request with changes to your Terraform code.
-
Terrateam automatically runs a Plan operation and comments on the pull request with the plan file output.
-
Review the plan file output and collaborate with your team to ensure the changes are as expected.
You can also manually trigger a Plan operation by commenting terrateam plan
on the pull request.
Apply
The Apply operation executes the plan generated by the Plan operation. It makes the actual changes to your infrastructure.
To trigger an Apply operation:
-
Ensure that the pull request has a successful Plan operation.
-
Comment
terrateam apply
on the pull request. -
Terrateam acquires a lock, runs the Apply operation, and comments on the pull request with the
terraform apply
output. -
Merge the pull request to complete the changes.
-
Terrateam 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
Terrateam can be configured to automatically apply changes when a pull request is merged. This is called Auto-Apply and can be enabled using When Modified.
Apply: Pre-merge Vs. Post-merge
Terrateam offers different workflows, primarily focusing on when to apply changes: before merge (pre-merge) or after merge (post-merge).
Choosing between pre-merge and post-merge workflows with Terrateam depends on your specific requirements and constraints. Pre-merge workflows provide greater safety and visibility at the cost of complexity and speed, whereas post-merge workflows offer simplicity and speed but with increased risk.
For environments where stability is paramount, implementing a pre-merge workflow with automerge enabled can offer a balanced approach, ensuring both thorough validation and efficient merging.