{"slug": "terrateam-plan-from-drift-issues", "title": "terrateam: plan from drift issues", "summary": "Terrateam, a GitHub-native infrastructure-as-code platform, now supports running `terrateam plan` from drift issues via a GitHub Actions relay that creates a temporary draft PR, enabling plan execution without pull request approval. The relay, developed by Perrotta, preserves Terrateam's locks, hooks, and credentials, and a live test returned 'Plan: 0 to add, 8 to change, 0 to destroy'. Apply remains unsupported because issues lack PR approval intent.", "body_md": "♠ **Problem statement**: Terrateam opens drift reports as GitHub issues, but `terrateam plan`\n\nonly works on pull requests.\n\nThe distinction is explicit in Terrateam’s [issue comment handler](https://github.com/terrateamio/terrateam/blob/cc723447ff80023b8627df6f8719bfb38462cf87/code/src/terrat_vcs_service_github/terrat_vcs_service_github_ep_events3.ml#L550-L655):\n\n```\n{ primary = Primary.{ number = pull_request_id; pull_request = Some _; _ }; _ };\n\n| Gw.Issue_comment_event.Issue_comment_created _ ->\n    Logs.debug (fun m -> m \"%s : NOOP : ISSUE_COMMENT_CREATED\" request_id);\n    Prmths.Counter.inc_one (Metrics.comment_events_total \"noop\");\n    Abbs_future_combinators.return_ok ()\n```\n\nCalling the repository workflow directly was not an option either. Its work token comes from the Terrateam backend.\n\nSo I kept Terrateam in charge and gave it the pull request it expects. A GitHub Actions relay checks that the source is an open Terrateam drift issue and that the commenter has repository write access. It then puts a comment-only Terraform file in each selected drift directory:\n\n```\nmarkers = [\n    InputGitTreeElement(\n        path=f\"{directory}/terrateam_issue_relay.tf\",\n        mode=\"100644\",\n        type=\"blob\",\n        content=f\"# Terrateam plan relay for drift issue #{issue_number}, comment {comment_id}.\\n\",\n    )\n    for directory in directories\n]\n```\n\nThat path change gives Terrateam a real dirspace without changing infrastructure. The relay opens a temporary draft PR and posts the original command on it:\n\n```\npull = repo.create_pull(\n    base=repo.default_branch,\n    head=branch,\n    title=f\"Terrateam plan relay for drift issue #{issue_number}\",\n    body=relay_body(issue_number, comment_id, event[\"comment\"][\"html_url\"]),\n    draft=True,\n)\npull.as_issue().create_comment(command)\n```\n\nTerrateam uses its normal locks, hooks, credentials, and batching. Another workflow copies its comments back to the drift issue. `apply`\n\nremains unsupported: an issue has no PR approval or review intent.\n\nThe live test planned the requested directory and returned the result:\n\n```\n## Plans :thumbsup:\n\n## Terrateam Plan Output :thumbsup:\n\n**Plan: 0 to add, 8 to change, 0 to destroy**\n```\n\nThe temporary PR ended where it should:\n\n```\n% gh pr view 6687 --json number,state,headRefName,title\n{\"headRefName\":\"bot/terrateam-issue-relay/6663-5398113346\",\"number\":6687,\"state\":\"CLOSED\",\"title\":\"Terrateam plan relay for drift issue #6663\"}\n% ./ci/run_python_tests.sh ci/terrateam_issue_relay\ncollected 19 items\ntests/test_relay.py ...................                                  [100%]\n============================== 19 passed in 1.45s ==============================\n```\n\nA scheduled job deletes inactive relay branches after 30 hours. Terrateam still owns plan execution; the relay only translates the issue command into its existing PR protocol.\n\n🤖 *Drafted with * ∎\n\n`/bloggify`\n\n.— § —\n\nReply via [email](mailto:serendipity@perrotta.dev?subject=Reply to: terrateam: plan from drift issues)", "url": "https://wpnews.pro/news/terrateam-plan-from-drift-issues", "canonical_source": "https://perrotta.dev/2026/08/terrateam-plan-from-drift-issues/", "published_at": "2026-08-24 16:38:39+00:00", "updated_at": "2026-08-24 17:13:19.643806+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools"], "entities": ["Terrateam", "GitHub Actions", "Perrotta"], "alternates": {"html": "https://wpnews.pro/news/terrateam-plan-from-drift-issues", "markdown": "https://wpnews.pro/news/terrateam-plan-from-drift-issues.md", "text": "https://wpnews.pro/news/terrateam-plan-from-drift-issues.txt", "jsonld": "https://wpnews.pro/news/terrateam-plan-from-drift-issues.jsonld"}}