Title: feat: Declarative script execution ordering in the Terraform provider · Issue #22365 · coder/coder · GitHub
Open Graph Title: feat: Declarative script execution ordering in the Terraform provider · Issue #22365 · coder/coder
X Title: feat: Declarative script execution ordering in the Terraform provider · Issue #22365 · coder/coder
Description: Originally posted by @ewengillies in #10352 Problem coder_script resources run concurrently. There is no Terraform-level way to declare execution ordering between scripts or modules. The current workaround (coder exp sync) requires manua...
Open Graph Description: Originally posted by @ewengillies in #10352 Problem coder_script resources run concurrently. There is no Terraform-level way to declare execution ordering between scripts or modules. The current wo...
X Description: Originally posted by @ewengillies in #10352 Problem coder_script resources run concurrently. There is no Terraform-level way to declare execution ordering between scripts or modules. The current wo...
Opengraph URL: https://github.com/coder/coder/issues/22365
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat: Declarative script execution ordering in the Terraform provider","articleBody":" _Originally posted by @ewengillies in [#10352](https://github.com/coder/coder/issues/10352#issuecomment-3970887647)_\n\n## Problem\n\n`coder_script` resources run concurrently. There is no Terraform-level way to declare execution ordering between scripts or modules. The current workaround (`coder exp sync`) requires manually instrumenting every bash script with signaling boilerplate and is experimental.\n\nThis causes race conditions, failed startups, and makes composable modules unreliable.\n\n## Use cases\n\n### UC1 — Sequential scripts within a template\n\nA template has scripts that must run in order: configure SSH keys → clone repo → install dependencies. Today these race.\n\n### UC2 — Script depends on a module completing\n\nA template-level script (e.g. \"run AI agent on repo\") needs all scripts from the `git-clone` module to finish first. The template author should not need to know the module's internal script names.\n\n### UC3 — Module depends on another module\n\nThe `claude-code` module depends on the `git-clone` module. All scripts in `claude-code` should wait for all scripts in `git-clone` to complete. This must work without either module author hardcoding the other's internals.\n\n### UC4 — \"Run before everything\" (inverse dependency)\n\nA script that configures apt mirrors must run before any other script installs packages — including scripts inside third-party modules. Today there is no way to express \"run me first\" without modifying every downstream script.\n\n### UC5 — Resource contention (dpkg/apt lock)\n\nMultiple scripts that use `apt-get` fail with lock conflicts when run concurrently. Ordering or mutual exclusion must be expressible to prevent this.\n\n### UC6 — AI agent multi-step workflow\n\nA user needs this exact sequence, reliably:\n1. Bootstrap user config (SSH keys, git config)\n2. Clone repo (requires 1)\n3. Run coding agent on cloned repo (requires 2)\n4. Push changes (requires 1-3)\n\nAll of these currently run in parallel, regularly failing. (Ref: [comment](https://github.com/coder/coder/issues/10352#issuecomment-3005930975))\n\n### UC7 — Preserve parallelism for independent scripts\n\nScripts with no ordering relationship must continue to run concurrently. Ordering is opt-in and should not regress startup times.\n\n### UC8 — Clear failure propagation\n\nIf a script fails, dependent scripts should be skipped with a clear error indicating which upstream dependency failed.\n\n## Constraints\n\n- The solution must work across modules from the Coder registry without requiring module consumers to know internal script names.\n- Module authors must be able to expose ordering interfaces for their scripts.\n- The mechanism should be declarative in Terraform, not require bash-level instrumentation.\n- An RFC is likely warranted given the public API surface and complexity. See prior discussion on trade-offs between `order`, `run_after`, `depends_on`, and CLI-based signaling in [#10352](https://github.com/coder/coder/issues/10352).\n\n## References\n\n- https://github.com/coder/coder/issues/10352 — original issue and extensive design discussion\n- https://github.com/coder/registry/issues/82 — module-level ordering\n- https://coder.com/docs/admin/templates/startup-coordination/ — current `coder exp sync` docs\n- [Agent as init system](https://github.com/coder/coder/issues/10352#issuecomment-2456460809) — @spikecurtis on learning from prior art\n- [Inverse dependency gap](https://github.com/coder/coder/issues/10352#issuecomment-2449977975) — @mafredri on the need to run *before* other scripts","author":{"url":"https://github.com/matifali","@type":"Person","name":"matifali"},"datePublished":"2026-02-27T10:43:57Z","url":"https://github.com/coder/coder/issues/22365"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4d1923db-6141-e1eb-e72f-b34cddeaa026 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CDF4:36A3E:1F66E67:29D7BAD:6B017CB8 |
| html-safe-nonce | e1b1b750c60aac3604ff1c38f0896c515488806a088055d37126de8c8567e93a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDREY0OjM2QTNFOjFGNjZFNjc6MjlEN0JBRDo2QjAxN0NCOCIsInZpc2l0b3JfaWQiOiIyMTMxMTc4NTYyMzcwMjM5NjcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 35843cab5d32aee2688a8eccc3b453ba02ab055054cbd7358caaa866f9c85266 |
| hovercard-subject-tag | issue:4000377212 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/22365/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e623c2b87a2ca6bf525d7170751217226ae0f95df577095b7b4d62aeb56d4f5e/coder/coder/issues/22365 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e623c2b87a2ca6bf525d7170751217226ae0f95df577095b7b4d62aeb56d4f5e/coder/coder/issues/22365 |
| og:image:alt | Originally posted by @ewengillies in #10352 Problem coder_script resources run concurrently. There is no Terraform-level way to declare execution ordering between scripts or modules. The current wo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | matifali |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width