trunk_merge_queue resource for creating, updating, importing, and deleting merge queues.
Current version: 0.1.3
Prerequisites
- Terraform >= 1.0
- An org-level API token from your Trunk organization. See Organization slug and token for how to generate one.
- A repository connected to Trunk
Authentication
Set your org-level API token using theTRUNK_API_KEY environment variable:
Quick Start
terraform plan to preview changes and terraform apply to apply them. If a merge queue already exists for the specified repository and branch, the provider will import it automatically rather than creating a duplicate.
Importing Existing Queues
Merge queues created through the UI or API can be imported into Terraform. This lets you start managing an existing queue as code without recreating it.{host}/{owner}/{name}/{target_branch}.
After importing, run terraform plan to compare the Terraform configuration against the current queue settings. Resolve any differences before running terraform apply.
Resource Reference: trunk_merge_queue
Required Attributes
The
repo and target_branch attributes are immutable. Changing any of them will destroy the existing queue and create a new one.Optional Attributes With API Defaults
These attributes are computed by the API if not specified. You only need to set them if you want to override the defaults.Other Optional Attributes
Managing Drift
When a merge queue is managed by Terraform, the Trunk UI displays a banner indicating that the queue is under Terraform management.

terraform apply to reconcile the configuration back to what is defined in Terraform, or update your .tf files to match the desired state.
Deleting a Queue
A merge queue must be empty before it can be deleted. If the queue still has PRs in it,terraform destroy will fail.
To empty a queue, you can set state = "DRAINING" and wait for all in-flight PRs to finish testing and merge. Once the queue is empty, run terraform destroy or remove the resource from your configuration and apply.
Terraform will fail to delete a queue that still has PRs in it. Ensure the queue is empty before destroying the resource.