title: Terraform count calling module output(return) error
body: <p>I need to return output of name and id only</p>
  <p>root main.tf</p>
  <pre><code># Azure Provider configuration
  provider &quot;azurerm&quot; {
    features {}
  }
  
  module &quot;rg&quot; {
    source              = &quot;../../modules/rg&quot;
    count               = length(var.resource_groups)
    resource_group_name = var.resource_groups[count.index].name
    tags                = {}
    location            = westus2
    lookup              = false
  }
  </code></pre>
  <p>module/rg/main.tf</p>
  <pre><code>resource &quot;azurerm_resource_group&quot; &quot;rg&quot; {
      count    = var.lookup == true ? 0 : 1
      name = var.resource_group_name
      location = var.location
      tags = var.tags
  }
  
  output &quot;rg_id&quot; {
    description = &quot;The id of the newly created rg&quot;
    value       = azurerm_resource_group.rg[count_index].id # azurerm_resource_group.rg, this statement will work
  }
  
  output &quot;rg_name&quot; {
    description = &quot;The name of the newly created rg&quot;
    value       = azurerm_resource_group.rg[count_index].name #  azurerm_resource_group.rg, this statement will work
  }
  </code></pre>
  <p>I am getting below error:</p>
  <p>A reference to a resource type must be followed by at least one attribute access, specifying the resource name.</p>