Applies API
An apply represents the results of applying a Terraform Run's execution plan.
Attributes
Apply States
You'll find the apply state in data.attributes.status
, as one of the following values.
State | Description |
---|---|
pending | The initial status of a apply once it has been created. |
managed_queued /queued | The apply has been queued, awaiting backend service capacity to run terraform. |
running | The apply is running. |
errored | The apply has errored. This is a final state. |
canceled | The apply has been canceled. This is a final state. |
finished | The apply has completed successfully. This is a final state. |
unreachable | The apply will not run. This is a final state. |
Show an apply
GET /applies/:id
Parameter | Description |
---|---|
id | The ID of the apply to show. |
There is no endpoint to list applies. You can find the ID for an apply in the
relationships.apply
property of a run object.
Status | Response | Reason |
---|---|---|
200 | JSON API document (type: "applies" ) | The request was successful |
404 | JSON API error object | Apply not found, or user unauthorized to perform action |
Sample Request
Sample Response
Using HCP Terraform agents
HCP Terraform agents allow HCP Terraform to communicate with isolated, private, or on-premises infrastructure. When a workspace is set to use the agent execution mode, the apply response will include additional details about the agent pool and agent used.
Recover a failed state upload after applying
GET /applies/:id/errored-state
Parameter | Description |
---|---|
id | The ID of the apply to recover state for. |
It is possible that during the course of a Run, Terraform may fail to upload a state file. This can happen for a variety of reasons, but should be an exceptionally rare occurance. HCP Terraform agent versions greater than 1.12.0 include a fallback mechanism which attempts to upload the state directly to HCP Terraform's backend storage system in these cases. This endpoint then makes the raw data from these failed uploads available to users who are authorized to read the state contents.
Status | Response | Reason |
---|---|---|
307 | HTTP temporary redirect to state storage URL | Errored state available and user is authorized to read it |
404 | JSON API error object | Apply not found, errored state not uploaded, or user unauthorized to perform action |
When a 307 redirect is returned, the storage URL to the raw state file will be
present in the Location
header of the response. The URL in the Location
header will expire after one minute. It is recommended for the API client to
follow the redirect immediately. Each successful request to the errored-state
endpoint will generate a new, unique storage URL with the same one minute
expiration window.
Sample Request
Sample Response