> For the complete documentation index, see [llms.txt](https://docs.terrakube.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.terrakube.io/2.34.0/run-terraform/workspaces/share-workspace-state.md).

# Share Workspace State

One workspace can read another workspace's outputs with the standard `terraform_remote_state` data source. This is how, for example, an application workspace reads the VPC id exported by a network workspace.

### Allow sharing

State is private by default. In the **producer** workspace open **Settings → State shared** and tick **Share this workspace's state with all workspaces in the organization**. Every workspace in the organization can then read it, and state can contain secrets, so only enable it when that is acceptable.

<figure><img src="https://1229094460-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTN6M529qVFnas8hChf2y%2Fuploads%2Fgit-blob-d37c759b23cbac40f340613ead7e44866748698c%2Fworkspace-state-shared.png?alt=media" alt="Settings, State shared"><figcaption><p>Settings, State shared</p></figcaption></figure>

### Read it from another workspace

In the **consumer** configuration use the `remote` backend and point it at your Terrakube hostname, organization and the producer workspace:

```hcl
data "terraform_remote_state" "network" {
  backend = "remote"
  config = {
    hostname     = "terrakube-api.example.com"
    organization = "simple"
    workspaces = {
      name = "network"
    }
  }
}

resource "aws_instance" "app" {
  subnet_id = data.terraform_remote_state.network.outputs.subnet_id
}
```

Only root-module **outputs** of the producer are readable. If the producer should trigger the consumer when it changes, add a [run trigger](/2.34.0/run-terraform/workspaces/run-triggers.md).

{% hint style="info" %}
Supported from Terrakube 2.15.0.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.terrakube.io/2.34.0/run-terraform/workspaces/share-workspace-state.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
