hello,
Terraform v0.12.24, provider.azurerm v2.49.0, local state
I am trying to create a vnet, but I want to have all of the required line items as variables that
are in the variables.auto.tfvars, whats the best way to go about this?
here is my code in main.tf:
#####begin vnet section##########################
resource “azurerm_virtual_network” “vnet” {
name = var.vnet_name
resource_group_name = var.rg_grp_name
address_space = var.vnet_cidr
location = var.region_location #match RG location
dns_servers = var.vnet_dns_servers
#tags stuff here
}
Resource “azurerm_subnet” “subnet” {
for_each = var.subnets
name = lookup(each.value, “name”)
resource_group_name = var.rg_grp_name
virtual_network_name = azurerm_virtual_network.vnet.name
address_prefix = lookup(each.value, “cidr”)
}
######end vnet section ######################
and here is my code in variables.tf, tho i am unsure about it.
###vnet section###################
#variable for defining what region
variable “name” {
type = string
}
#variable for defining what region
variable “resource_group_name” {
type = string
}
#variable for defining what region
variable “vnet_cidr” {
description = “address space”
type = list
}
#variable for defining what region
variable “region_location” {
type = string
}
#variable for defining what region
variable “vnet_dns_servers” {
type = list
}
#variable for defining what region
variable “subnets” {
type = map(object({
name = string
cidr = string
}))
}
##end subnet block
}
#####end vnet section#############
I dont have anything for variables.auto.tfvars yet.