Skip to content

Commit

Permalink
Merge pull request hashicorp#227 from hashicorp/nf/dec-22-state-versi…
Browse files Browse the repository at this point in the history
…on-api-async-processing

TFC API docs: Add information about async processing of state version info
  • Loading branch information
nfagerlund authored Dec 20, 2022
2 parents f97fc43 + b507909 commit 2421870
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions website/docs/cloud-docs/api-docs/state-version-outputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ page_title: State Version Outputs - API Docs - Terraform Cloud
State version outputs are the [output values](/language/values/outputs) from a Terraform state file. They include
the name and value of the output, as well as a sensitive boolean if the value should be hidden by default in UIs.

~> **Important:** The state version outputs for a state version (as well as some other information about it) might be **populated asynchronously** by Terraform Cloud. These values might not be immediately available after the state version is uploaded. The `resources-processed` property on the associated [state version object](/cloud-docs/api-docs/state-versions) indicates whether or not Terraform Cloud has finished any necessary asynchronous processing. If you need to use these values, be sure to wait for `resources-processed` to become `true` before assuming that the values are in fact empty.

## List State Version Outputs

`GET /state-versions/:state_version_id/outputs`
Expand Down
22 changes: 20 additions & 2 deletions website/docs/cloud-docs/api-docs/state-versions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ page_title: State Versions - API Docs - Terraform Cloud

# State Versions API

## Attributes

State version API objects represent an instance of Terraform state data, but do not directly contain the stored state. Instead, they contain information about the state, its properties, and its contents, and include one or more URLs from which the state can be downloaded.

Some of the information returned in a state version API object might be **populated asynchronously** by Terraform Cloud. This includes resources, modules, providers, and the [state version outputs](/cloud-docs/api-docs/state-version-outputs) associated with the state version. These values might not be immediately available after the state version is uploaded. The `resources-processed` property on the state version object indicates whether or not Terraform Cloud has finished any necessary asynchronous processing. If you need to use these values, be sure to wait for `resources-processed` to become `true` before assuming that the values are in fact empty.

Attribute | Description
---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
`hosted-json-state-download-url` | A URL from which you can download the state data in a [stable format](/internals/json-format) appropriate for external integrations to consume. Only available if the state was created by Terraform 1.3+.
`hosted-state-download-url` | A URL from which you can download the raw state data, in the format used internally by Terraform.
`modules` | Extracted information about the Terraform modules in this state data. Populated asynchronously.
`providers` | Extracted information about the Terraform providers used for resources in this state data. Populated asynchronously.
`resources` | Extracted information about the resources in this state data. Populated asynchronously.
`resources-processed` | A Boolean flag indicating whether Terraform Cloud has finished asynchronously extracting outputs, resources, and other information about this state data.
`serial` | The serial number of this state instance, which increases every time Terraform creates new state in the workspace.
`state-version` | The version of the internal state format used for this state. Different Terraform versions read and write different format versions, but it only changes infrequently.
`terraform-version` | The Terraform version that created this state. Populated asynchronously.
`vcs-commit-sha` | The SHA of the configuration commit used in the Terraform run that produced this state. Only present if the workspace is connected to a VCS repository.
`vcs-commit-url` | A link to the configuration commit used in the Terraform run that produced this state. Only present if the workspace is connected to a VCS repository.

## Create a State Version

> **Hands-on:** Try the [Version Remote State with the Terraform Cloud API](https://learn.hashicorp.com/tutorials/terraform/cloud-state-api?in=terraform/cloud) tutorial to download a remote state file and use the Terraform API to create a new state version.
Expand Down Expand Up @@ -122,8 +142,6 @@ curl \

### Sample Response

-> **Note**: The `hosted-state-download-url` attribute provides a URL from which you can download the raw, internal state. When Terraform 1.3+ is used, the `hosted-json-state-download-url` attribute provides the same state, but in a [stable format](/internals/json-format).

```json
{
"data": {
Expand Down

0 comments on commit 2421870

Please sign in to comment.