github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/azurerm/r/virtual_network.html.markdown (about) 1 --- 2 layout: "azurerm" 3 page_title: "Azure Resource Manager: azure_virtual_network" 4 sidebar_current: "docs-azurerm-resource-network-virtual-network" 5 description: |- 6 Creates a new virtual network including any configured subnets. Each subnet can optionally be configured with a security group to be associated with the subnet. 7 --- 8 9 # azurerm\_virtual\_network 10 11 Creates a new virtual network including any configured subnets. Each subnet can 12 optionally be configured with a security group to be associated with the subnet. 13 14 ## Example Usage 15 16 ```hcl 17 resource "azurerm_virtual_network" "test" { 18 name = "virtualNetwork1" 19 resource_group_name = "${azurerm_resource_group.test.name}" 20 address_space = ["10.0.0.0/16"] 21 location = "West US" 22 dns_servers = ["10.0.0.4", "10.0.0.5"] 23 24 subnet { 25 name = "subnet1" 26 address_prefix = "10.0.1.0/24" 27 } 28 29 subnet { 30 name = "subnet2" 31 address_prefix = "10.0.2.0/24" 32 } 33 34 subnet { 35 name = "subnet3" 36 address_prefix = "10.0.3.0/24" 37 security_group = "${azurerm_network_security_group.test.id}" 38 } 39 40 tags { 41 environment = "Production" 42 } 43 } 44 ``` 45 46 ## Argument Reference 47 48 The following arguments are supported: 49 50 * `name` - (Required) The name of the virtual network. Changing this forces a 51 new resource to be created. 52 53 * `resource_group_name` - (Required) The name of the resource group in which to 54 create the virtual network. 55 56 * `address_space` - (Required) The address space that is used the virtual 57 network. You can supply more than one address space. Changing this forces 58 a new resource to be created. 59 60 * `location` - (Required) The location/region where the virtual network is 61 created. Changing this forces a new resource to be created. 62 63 * `dns_servers` - (Optional) List of IP addresses of DNS servers 64 65 * `subnet` - (Optional) Can be specified multiple times to define multiple 66 subnets. Each `subnet` block supports fields documented below. 67 68 * `tags` - (Optional) A mapping of tags to assign to the resource. 69 70 The `subnet` block supports: 71 72 * `name` - (Required) The name of the subnet. 73 74 * `address_prefix` - (Required) The address prefix to use for the subnet. 75 76 * `security_group` - (Optional) The Network Security Group to associate with 77 the subnet. (Referenced by `id`, ie. `azurerm_network_security_group.test.id`) 78 79 ## Attributes Reference 80 81 The following attributes are exported: 82 83 * `id` - The virtual NetworkConfiguration ID. 84 85 * `name` - The name of the virtual network. 86 87 * `resource_group_name` - The name of the resource group in which to create the virtual network. 88 89 * `location` - The location/region where the virtual network is created 90 91 * `address_space` - The address space that is used the virtual network. 92 93 94 ## Import 95 96 Virtual Networks can be imported using the `resource id`, e.g. 97 98 ``` 99 terraform import azurerm_virtual_network.testNetwork /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/virtualNetworks/myvnet1 100 ```