github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/terraform/d/remote_state.html.md (about)

     1  ---
     2  layout: "terraform"
     3  page_title: "Terraform: terraform_remote_state"
     4  sidebar_current: "docs-terraform-datasource-remote-state"
     5  description: |-
     6    Accesses state meta data from a remote backend.
     7  ---
     8  
     9  # remote_state
    10  
    11  Retrieves state meta data from a remote backend
    12  
    13  ## Example Usage
    14  
    15  ```hcl
    16  data "terraform_remote_state" "vpc" {
    17    backend = "atlas"
    18    config {
    19      name = "hashicorp/vpc-prod"
    20    }
    21  }
    22  
    23  resource "aws_instance" "foo" {
    24    # ...
    25    subnet_id = "${data.terraform_remote_state.vpc.subnet_id}"
    26  }
    27  ```
    28  
    29  ## Argument Reference
    30  
    31  The following arguments are supported:
    32  
    33  * `backend` - (Required) The remote backend to use.
    34  * `environment` - (Optional) The Terraform environment to use.
    35  * `config` - (Optional) The configuration of the remote backend.
    36   * Remote state config docs can be found [here](/docs/backends/types/terraform-enterprise.html)
    37  
    38  ## Attributes Reference
    39  
    40  The following attributes are exported:
    41  
    42  * `backend` - See Argument Reference above.
    43  * `config` - See Argument Reference above.
    44  
    45  In addition, each output in the remote state appears as a top level attribute
    46  on the `terraform_remote_state` resource.
    47  
    48  ## Root Outputs Only
    49  
    50  Only the root level outputs from the remote state are accessible. Outputs from
    51  modules within the state cannot be accessed. If you want a module output to be
    52  accessible via a remote state, you must thread the output through to a root
    53  output.
    54  
    55  An example is shown below:
    56  
    57  ```hcl
    58  module "app" {
    59    source = "..."
    60  }
    61  
    62  output "app_value" {
    63    value = "${module.app.value}"
    64  }
    65  ```
    66  
    67  In this example, the output `value` from the "app" module is available as
    68  "app_value". If this root level output hadn't been created, then a remote state
    69  resource wouldn't be able to access the `value` output on the module.