Home > Blockchain >  how to pass subnet to tfvars? using terraform for azure subnets
how to pass subnet to tfvars? using terraform for azure subnets

Time:11-16

i have a subnet module like this:

    module "subnet" {
  source = "../../azurerm/azurerm-subnet"

  business_unit       = var.business_unit
  location            = var.location
  region              = var.region
  resource_group_name  = var.vnet_resource_group
  virtual_network_name = var.virtual_network_name
  address_prefixes     = var.address_prefixes
}

how can pass these values to a tfvars file?

CodePudding user response:

During your terraform plan execution you should pass your values in a tfvars file. command: terraform plan "-var-file=subnet.tfvars" In your subnet.tfvars pass values like this:

business_unit       = "IT"
location            = "Your VNET Location"
region              = "..."
resource_group_name  = "Your VNET RG Name"
virtual_network_name = "Your VNET Name"
address_prefixes     = "A suitable address prefix like 10.0.1.0/24"

CodePudding user response:

ok so another problem with that is, my region deployment is based on tf vars, i am sure i cant use 2 "resource_group_name" within the same tfvars file? because for each subscription i would need to create a RG for it...

  • Related