Run task stages and results API reference
HCP Terraform uses run task stages and run task results to track run task execution.
Note: HCP Terraform Free Edition includes one run task integration that you can apply to up to ten workspaces. Refer to HCP Terraform pricing for details.
When HCP Terraform creates a run, it reads the run tasks associated to the workspace. Each run task in the workspace is configured to begin during a specific run stage. HCP Terraform creates a run task stage object for each run stage that triggers run tasks. You can configure run tasks during the Pre-Plan Stage, Post-Plan Stage, Pre-Apply Stage and Post-Apply Stage.
Run task stages then create a run task result for each run task. For example, a workspace has two run tasks called alpha
and beta
. For each run, HCP Terraform creates one run task stage called post-plan
. That run task stage has two run task results: one for the alpha
run task and one for the beta
run task.
This page lists the endpoints to retrieve run task stages and run task results. Refer to the Run Tasks API for endpoints to create and manage run tasks within HCP Terraform. Refer to the Run Tasks Integration API for endpoints to build custom run tasks for the HCP Terraform ecosystem.
Attributes
Run Task Stage Status
The run task stage status is found in data.attributes.status
, and you can reference the following list of possible values.
Status | Description |
---|---|
pending | The initial status of a run task stage after creation. |
running | The run task stage is executing one or more tasks, which have not yet completed. |
passed | All of the run task results in the stage passed. |
failed | One more results in the run task stage failed. |
awaiting_override | The task stage is waiting for user input. Once a user manually overrides the failed run tasks, the run returns to the running state. |
errored | The run task stage has errored. |
canceled | The run task stage has been canceled. |
unreachable | The run task stage could not be executed. |
Run Task Result Status
The run task result status is found in data.attributes.status
, and you can reference the following list of possible values.
Status | Description |
---|---|
pending | The initial status of a run task result after creation. |
running | The associated run task is begun execution and has not yet completed. |
passed | The associated run task executed and returned a passing result. |
failed | The associated run task executed and returned a failed result. |
errored | The associated run task has errored during execution. |
canceled | The associated run task execution has been canceled. |
unreachable | The associated run task could not be executed. |
List the Run Task Stages in a Run
GET /runs/:run_id/task-stages
Parameter | Description |
---|---|
run_id | The run ID to list task stages for. |
Status | Response | Reason |
---|---|---|
200 | Array of JSON API documents (type: "task-stages" ) | Successfully listed task-stages |
Query Parameters
This endpoint supports pagination with standard URL query parameters; remember to percent-encode [
as %5B
and ]
as %5D
if your tooling doesn't automatically encode URLs.
Parameter | Description |
---|---|
page[number] | Optional. If omitted, the endpoint will return the first page. |
page[size] | Optional. If omitted, the endpoint will return 20 runs per page. |
Sample Request
Sample Response
Show a Run Task Stage
GET /task-stages/:task_stage_id
Parameter | Description |
---|---|
:task_stage_id | The run task stage ID to get. |
This endpoint shows details of a specific task stage.
Status | Response | Reason |
---|---|---|
200 | JSON API document (type: "task-stages" ) | Success |
404 | JSON API error object | Task stage not found or user not authorized |
Sample Request
Sample Response
Show a Run Task Result
GET /task-results/:task_result_id
Parameter | Description |
---|---|
:task_result_id | The run task result ID to get. |
This endpoint shows the details for a specific run task result.
Status | Response | Reason |
---|---|---|
200 | JSON API document (type: "task-results" ) | Success |
404 | JSON API error object | Task result not found or user not authorized |
Sample Request
Sample Response
Available Related Resources
Task Stage
The GET endpoints above can optionally return related resources, if requested with the include
query parameter. The following resource types are available:
Resource | Description |
---|---|
run | Information about the associated run. |
run.workspace | Information about the associated workspace. |
task-results | Information about the results for a task-stage. |
policy-evaluations | Information about the policy evaluations for a task-stage. |
Override a Task Stage
POST /task-stages/:task_stage_id/actions/override
Parameter | Description |
---|---|
:task_stage_id | The ID of the task stage to override. |
Sample Request
Sample Response