title: Referencing terraform_remote_state from within module
body: <p>Using Terraform v0.13.5</p>
  <p>I have a module which has some outputs derived from some sub modules within it, e.g.:</p>
  <pre><code>module &quot;egressvnet&quot; {
    source = &quot;../modules/vnet/egress&quot;
  }
  
  output &quot;subnet&quot; {
    value = module.egressvnet.subnet
  }
  </code></pre>
  <p><code>terraform output</code> confirms that what I expect to be outputted is.</p>
  <p>Within another terraform setup I would like to reference the outputs from the above.</p>
  <p>So I have this in my terraform config:</p>
  <pre><code>data &quot;terraform_remote_state&quot; &quot;network&quot; {
    backend = &quot;azurerm&quot;
  
    config = {
      resource_group_name  = &quot;xxx&quot;
      storage_account_name = &quot;xxx&quot;
      container_name       = &quot;terraform&quot;
      key                  = &quot;network.tfstate&quot;
    }
  }
  
  module &quot;web&quot; {
    source = &quot;../modules/web&quot;
  
    subnet_id = terraform_remote_state.network.outputs.subnet
  
  }
  Is what I'm trying to do possible?
  </code></pre>
  <p>But when I do a plan I get this error:</p>
  <pre><code>Error: Reference to undeclared resource
  
    on base.tf line 111, in module &quot;web&quot;:
   111:   subnet_id = terraform_remote_state.network.outputs.subnet
  
  A managed resource &quot;terraform_remote_state&quot; &quot;network&quot; has not been declared in
  the root module.
  </code></pre>