-
Notifications
You must be signed in to change notification settings - Fork 2
/
virtual_network.tf
25 lines (21 loc) · 952 Bytes
/
virtual_network.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#########################################################
# vnet_create (used for storage account network rule)
# => ``null` then no vnet created or attached (default)
# => ``true` then enable creation of new vnet
# => ``false` then point to existing vnet
#########################################################
resource "azurerm_virtual_network" "pgsql" {
count = (var.vnet_create == true) ? 1 : 0
name = var.vnet_name
location = var.vnet_rg
resource_group_name = var.resource_group
address_space = [var.vnet_cidr]
}
resource "azurerm_subnet" "pgsql" {
count = (var.vnet_create == true) ? 1 : 0
name = var.subnet_name
resource_group_name = var.vnet_rg
virtual_network_name = var.vnet_create ? azurerm_virtual_network.pgsql[0].name : data.azurerm_virtual_network.pgsql[0].name
address_prefixes = var.subnet_address_prefixes
service_endpoints = ["Microsoft.Storage"]
}