-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr-network.tf
34 lines (29 loc) · 1.36 KB
/
r-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
26
27
28
29
30
31
32
33
34
locals {
subnet_id = var.subnet_id == null ? azurerm_subnet.this[0].id : var.subnet_id
}
resource "azurerm_virtual_network" "this" {
count = var.create_subnet ? 1 : 0
name = join("-", compact(["vnet", var.name, "prd", local.location_short[var.location], var.name_suffix]))
resource_group_name = var.resource_group_name
location = var.location
tags = var.tags
address_space = var.virtual_network_address_space
}
resource "azurerm_subnet" "this" {
count = var.create_subnet ? 1 : 0
name = join("-", compact(["snet", var.name, "prd", local.location_short[var.location], var.name_suffix]))
resource_group_name = var.resource_group_name
virtual_network_name = azurerm_virtual_network.this[0].name
address_prefixes = var.subnet_address_prefixes
service_endpoints = var.service_endpoints
}
resource "azurerm_network_security_group" "this" {
name = join("-", compact(["nsg", var.name, "prd", local.location_short[var.location], var.name_suffix]))
location = var.location
resource_group_name = var.resource_group_name
tags = var.tags
}
resource "azurerm_subnet_network_security_group_association" "this" {
subnet_id = local.subnet_id
network_security_group_id = azurerm_network_security_group.this.id
}