Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting vnet data and supporting different RGs for VM & VNet #12

Open
tohewi opened this issue Nov 25, 2021 · 2 comments
Open

Splitting vnet data and supporting different RGs for VM & VNet #12

tohewi opened this issue Nov 25, 2021 · 2 comments

Comments

@tohewi
Copy link

tohewi commented Nov 25, 2021

Hi,

Instead of having local data on vnet:

data "azurerm_virtual_network" "vnet" {
  name                = var.virtual_network_name
  resource_group_name = data.azurerm_resource_group.rg.name
}

would you please consider having the possibility to provide network map as input to the module.

I am using a map like this to

locals {
  vnet_map = merge(
	var.vnet_map,
    {
    dev = {
      vnet = "${data.azurerm_virtual_network.pe_dev_vnet01.id}"
      default_subnet = "${data.azurerm_subnet.pe_dev_vnet01_subnet01.id}"
    }
    test = {
      vnet = "${data.azurerm_virtual_network.pe_test_vnet01.id}"
      default_subnet = "${data.azurerm_subnet.pe_test_vnet01_subnet01.id}"
    }
    prod = {
      vnet = "${data.azurerm_virtual_network.pe_prod_vnet01.id}"
      default_subnet = "${data.azurerm_subnet.pe_prod_vnet01_subnet01.id}"
    }
    },
  )
}

to create an environment specific map of vnet and subnet ids.

This would help keeping vnet data consistently in one "module" and also support cases where VNETs and VMs are in different resource groups.

@kumarvna
Copy link
Owner

You can use meta arguments (for_each and count) with this module to achieve any requirement. This module is more of a general purpose and can be utilised for more complex scenarios using meta arguments. Please check this link for more information.
https://www.terraform.io/language/meta-arguments/for_each

@jakubigla
Copy link

jakubigla commented Dec 21, 2022

Hi @kumarvna I don't think you understand the issue here. You can't use VNET for the VM if it's deployed in the different resource group. the module assumes that the VNET is deployed in the same resource group as the VM will be.
subnet_id parameter would resolve this.
This is preventing me from using this module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants