title: Error: Unsupported attribute. This object does not have an attribute named "nsg_name"
body: <p>NSG gets created fine, so then I create and enter all the config for the nsg rules in my env/dev and modules folders
  <br/>
  I run terraform plan, this is the error I am getting:</p>
  <p>Error: Unsupported attribute</p>
  <p>on nsg_rules.tf line 6, in module &quot;nsgrules_app1&quot;:</p>
  <p>6:   nsg_name                  = module.nsg_app1.nsg_name</p>
  <p>This object does not have an attribute named &quot;nsg_name&quot;.</p>
  <br/>
  I know my code is incorrect, i'm just not sure how to write up the nsg_rule module by using map variables and then attach it to the NSG in my other module.
  <p>Any assistance would be appreciated :)
  <br/></p>
  <p>my terraform relevant folder structure is:</p>
  <pre><code>dev
      |_ backend.tf
      |_ outputs.tf
      |_ provider.tf
      |_ resource_groups.tf
      |_ nsg.tf
      |_ nsg_rules.tf
      |_ storage.tf
      |_ subnets.tf
      |_ variables.tf
      |_ vnets.tf
      |_ vms_lin.tf
  
  modules
  |_ nsg
            |_ outputs.tf
            |_ variables.tf
            |_ main.tf
  
  |_ nsg_rules
            |_ outputs.tf
            |_ variables.tf
            |_ main.tf
  
  |_ resource_group
            |_ outputs.tf
            |_ variables.tf
            |_ main.tf
  |_ storage
            |_ outputs.tf
            |_ variables.tf
            |_ main.tf
  |_ network
            |_ vnet
                   |_ outputs.tf
                   |_ variables.tf
                   |_ main.tf
            |_ subnet
                   |_ outputs.tf
                   |_ variables.tf
                   |_ main.tf
  </code></pre>
  <p>dev/nsg.tf</p>
  <pre><code>module &quot;nsg_app1&quot; {
    source                    = &quot;git::ssh://git@ssh.dev.azure.com/v3/myorg/my_code/terraform_modules//nsg&quot;
    nsg_name                  = &quot;nsg-ansible&quot;
    rg_name                   = module.rg_app1.rg_name
    location                  = module.rg_app1.rg_location
  }
  </code></pre>
  <p>dev/nsg_rules.tf</p>
  <pre><code>module &quot;nsgrules_app1&quot; {
    source                    = &quot;git::ssh://git@ssh.dev.azure.com/v3/myorg/my_code/terraform_modules//nsg_rule&quot;
    rg_name                   = module.rg_app1.rg_name
    nsg_name                  = module.nsg_app1.nsg_name
    # rules_map                 = var.rules_map     
    # rules_map = {
    #   http_inbound  = { priority = 150, direction = &quot;Inbound&quot;, access = &quot;Allow&quot;, protocol = &quot;TCP&quot;, destination_port_range = &quot;80&quot; },
    #   https_inbound = { priority = 151, direction = &quot;Inbound&quot;, access = &quot;Allow&quot;, protocol = &quot;TCP&quot;, destination_port_range = &quot;443&quot; }
    # }
  }
  </code></pre>
  <p>modules/nsg/main.tf</p>
  <pre><code>resource &quot;azurerm_network_security_group&quot; &quot;nsg&quot; {
    name                = var.nsg_name
    location            = var.location
    resource_group_name = var.rg_name
  }
  </code></pre>
  <p>modules/nsg/variables.tf</p>
  <pre><code>variable &quot;rg_name&quot; {
    description = &quot;name of resource group&quot;
  }
  
  variable &quot;location&quot; {
    description = &quot;location of resource group&quot;
  }
  
  variable &quot;nsg_name&quot; {
    description = &quot;name of nsg group&quot;
  }
  </code></pre>
  <p>modules/nsg_rule/main.tf</p>
  <pre><code>resource &quot;azurerm_network_security_rule&quot; &quot;nsg-rule-rdp&quot; {
      
    name                        = &quot;RDP&quot;
    priority                    = &quot;105&quot;
    direction                   = &quot;Inbound&quot;
    access                      = &quot;Allow&quot;
    protocol                    = &quot;TCP&quot;
    source_port_range           = &quot;*&quot;
    destination_port_range      = &quot;3389&quot;
    source_address_prefixes     = var.default_ip_whitelist
    destination_address_prefix  = &quot;*&quot;
    resource_group_name         = var.rg_name
    network_security_group_name = var.nsg_name
  }
  </code></pre>
  <p>modules/nsg_rule/variables.tf</p>
  <pre><code>variable &quot;rg_name&quot; {
    description = &quot;name of resource group&quot;
  }
  
  variable &quot;default_ip_whitelist&quot; {
    description = &quot;List of IPs to whitelist on all RDP | SSH enabled NSG rules.&quot;
    default     = []
  }
  
  variable &quot;nsg_name&quot; {
    description = &quot;name of nsg group&quot;
  }
  
  variable &quot;rules_map&quot; {
    type    = map
    default = {
          rule1 = {priority = 105, direction = &quot;Inbound&quot;, access = &quot;Allow&quot;, protocol = &quot;TCP&quot;, source_port_range = &quot;*&quot;, destination_port_range = &quot;*&quot;,source_address_prefix = &quot;*&quot;, destination_address_prefix = &quot;*&quot;  } ,
          rule2 = {priority = 105, direction = &quot;Outbound&quot;, access = &quot;Deny&quot;, protocol = &quot;TCP&quot;, source_port_range = &quot;*&quot;, destination_port_range = &quot;*&quot;,source_address_prefix = &quot;*&quot;, destination_address_prefix = &quot;*&quot;  }    
      }
  
  }
  </code></pre>