title: Self link modules in terraform
body: <p>I have the following terraform code snippet where I'm trying to use a self_link in the subnet.network resource that references the title of the network resource.</p>
  <p>main.tf</p>
  <pre><code>resource &quot;google_compute_network&quot; &quot;demo-vpc-network&quot; {
    auto_create_subnetworks         = &quot;false&quot;
    delete_default_routes_on_create = &quot;false&quot;
    name                            = var.GCP_COMPUTE_NETWORK_NAME
    project                         = var.GCP_PROJECT_NAME
    routing_mode                    = &quot;REGIONAL&quot;
  }
   
  resource &quot;google_compute_subnetwork&quot; &quot;demo-subnet&quot; {
    ip_cidr_range            = &quot;10.200.0.0/24&quot;
    name                     = &quot;kubernetes&quot;
    network                  = google_compute_network.vpc_network.self.link
    private_ip_google_access = &quot;false&quot;
    project                  = var.GCP_PROJECT_NAME
    region                   = &quot;us-west1&quot;
  }
  </code></pre>
  <p>However, I get the following error.</p>
  <pre><code>Error: Reference to undeclared resource
  
    on main.tf line 77, in resource &quot;google_compute_subnetwork&quot; &quot;demo-subnet&quot;:
    77:   network                  = google_compute_network.vpc_network.self.link
  
  A managed resource &quot;google_compute_network&quot; &quot;vpc_network&quot; has not been
  declared in the root module.
  </code></pre>