run start: add --wait to block until the run finishes#87
Open
jordanenglish wants to merge 1 commit into
Open
Conversation
`run start --wait` polls the newly created run to a terminal state, streaming each status transition, and maps the outcome to an exit code: applied / planned_and_finished / planned_and_saved succeed, while errored, canceled, discarded, and policy failures exit non-zero. A plan that finishes but needs a manual apply (auto-apply disabled) stops rather than hanging. --timeout bounds the wait; if it elapses, tfctl stops watching and exits non-zero, but the run keeps running in HCP Terraform. On completion the elapsed time and run URL are printed. The final summary reuses the same renderer as `run status`.
jordanenglish
marked this pull request as ready for review
July 17, 2026 06:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
run startreturns as soon as the run is created, so automating a plan/apply means hand-rolling a poll loop againstrun status. This adds--wait, which blocks until the run reaches a terminal state and maps the outcome to an exit code, sorun startis usable directly in scripts and CI.Behavior
applied/planned_and_finished/planned_and_savedexit0;errored,canceled,discarded, and mandatory policy failures (policy_soft_failed,policy_override) exit non-zero.actions.is-confirmable.--timeoutbounds the wait. If it elapses, tfctl stops watching and exits non-zero, but the run keeps running in HCP Terraform (this is a watch budget, not a cancel); the run URL is surfaced so you can follow up.run status(diagnostics, policy failures, task results).Example Output
Wait through an auto-apply run:
Plan-only, or a workspace without auto-apply, stops for a manual apply rather than hanging:
Timeout leaves the run running server-side and exits non-zero:
PR Checklist
npx changie newor install changie to prepare a new changelog entry for the next set of release notes..changes/unreleased/ENHANCEMENTS-*.yaml(kind: ENHANCEMENTS).--json— Force machine readable output to stdout. Does not apply to stderr.--markdown— Force markdown output to stdout. Does not apply to stderr.--dry-run— Don't make any actual writes or other mutations. Describe what would have changed to stderr.--quiet— Don't render output to stdout.run statusOutputter, so it honors--json/--markdown/--quietidentically torun status.--waitis a no-op under--dry-run(dry-run returns before any run is created).make gen/screenshotif the root command output changes.run startgains flags; the root command output is unchanged.Autocompletefield to positional arguments and flags to assist shell autocomplete.--waitis boolean and--timeouttakes a freeform duration; neither has an enumerable completion set (consistent with the siblingrun startboolean/value flags).PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
--waitonly polls read-only run status with the existing token; no auth, permission, or other security-control surface is changed.