trunk_merge_queue resource. The Registry documentation lists every attribute.
Current version: 2.0.1. Upgrading from 1.x? See Migrate to provider 2.0.
Prerequisites
- Terraform >= 1.0
- A Trunk API key with the Update Merge Queue settings permission, created by an organization admin
- A repository connected to Trunk
Authentication
Set the API key in theTRUNK_API_KEY environment variable:
queue_id, managed_state, import by ID, batching_max_wait_time_minutes = 0, or updating queues on hosts other than github.com, such as GitHub Enterprise.
base_url (or TRUNK_BASE_URL) sets the API host, https://api.trunk.io by default. api_key and base_url must be known at plan time, so apply anything they depend on first.
Quick start
terraform init, terraform plan and terraform apply. If the queue already exists, apply fails with Merge queue already exists; import it instead.
What Terraform manages
Only the settings in your configuration; others keep their current value, or Trunk’s default for a new queue. Set Slack notifications, impacted targets from fork PRs and bot approvals (Settings → Organization → Bots) in the Trunk app.Importing existing queues
Add atrunk_merge_queue block for the queue, then import it:
merge-queue/ in the queue’s Trunk app URL, or queue_id in terraform state show. After importing, resolve any differences terraform plan shows before you apply.
Resource reference: trunk_merge_queue
Values are lowercase, as written below.
Required attributes
Changing any of them replaces the queue.
Settings
With an API key, an apply above a v2 cap fails, such as
concurrency over 1000 or not_ready_timeout_hours over 720 (all limits).
Read-only attributes
Required statuses
required_statuses overrides .trunk/trunk.yaml and branch protection. Leave it out to keep the current override, or set [] to remove it. Order doesn’t matter.
Batching rules
target_pattern matches an impacted target exactly, or as a prefix when it ends in *; "isolate" tests a matching PR on its own. Rules apply only in "parallel" mode, and [] removes them all.
Managing drift
The Trunk app shows a banner on queues Terraform manages.
Banner for Merge Queue settings showing that the Merge Queue is managed by Terraform.

Banner for Merge Queue settings showing that the Merge Queue is managed by Terraform but has since drifted due to settings being changed manually in the UI.
managed_state = "terraform_with_drift") until an apply next changes it.
With an API key, once queue_id is recorded, Terraform doesn’t take over a queue recreated outside it; import the new one.
Switching modes
Changingmode drains the queue and switches once it’s empty; until then, other changes to the queue fail. To cancel, click Cancel next to Switching to … Mode in the queue’s settings, then set mode back.
If creating a queue fails partway
Terraform marks the half-created queue tainted, so the next apply recreates it; runterraform untaint trunk_merge_queue.<name> first to keep it instead.
Deleting a queue
Only an empty queue can be deleted: setstate = "draining", apply, wait for in-flight PRs to finish, then run terraform destroy.