> ## Documentation Index
> Fetch the complete documentation index at: https://docs.envzero.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Remote state data source

> Use the terraform_remote_state data source to read outputs from env zero remote backend state, sharing VPC IDs and endpoints across Terraform stacks.

Terraform allows you to utilize the remote state as a data source.  This is particularly useful for retrieving dependent information from a parent resource.

env zero's [remote state](https://docs.envzero.com/guides/admin-guide/remote-backend.md) can be used with [Terraform Remote State Data Source](https://developer.hashicorp.com/terraform/language/state/remote-state-data).

```hcl theme={null}
data "terraform_remote_state" "example" {
  backend = "remote"

  config = {
    hostname     = "backend.api.env0.com"
    organization = "[ORGANIZATION_ID]"
    workspaces = {
      name = "[WORKSPACE_NAME]"
    }
  }
}
```

> [!NOTE]
>
> **The WORKSPACE\_NAME is unique per organization.**

Here's an example of how its used:

```hcl theme={null}
provider "aws" {
  region = "us-west-2"
}

data "terraform_remote_state" "vpc" {
  backend = "remote"

  config = {
    hostname     = "backend.api.env0.com"
    organization = "aaaaaaaa-bbbb-cccc-dddd-8f43fe49db92"
    workspaces = {
      name = "acme-fitness-agent-vpc"
    }
  }
}

output "vpc_id" {
  value = data.terraform_remote_state.vpc.outputs.vpc_id
}
```

## Further reading

* [Manage Terraform remote state with a remote backend](https://www.envzero.com/blog/terraform-remote-state-using-a-remote-backend)

## Next steps

* [Allow the reading environment's project to access the state](https://docs.envzero.com/guides/admin-guide/remote-backend/state-access-control.md)
* [Pass values through environment outputs](https://docs.envzero.com/guides/admin-guide/variables/environment-outputs.md) instead of reading the state directly


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.