generated from Azure/terraform-azurerm-avm-template
-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.virtual.network.tf
61 lines (51 loc) · 2.32 KB
/
main.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
module "virtual_network" {
count = var.use_private_networking && var.virtual_network_creation_enabled ? 1 : 0
source = "Azure/avm-res-network-virtualnetwork/azurerm"
version = "0.7.1"
name = local.virtual_network_name
resource_group_name = local.resource_group_name
location = var.location
address_space = [var.virtual_network_address_space]
subnets = merge(local.final_subnets, {
container_registry_private_endpoint = {
name = local.container_registry_private_endpoint_subnet_name
address_prefix = local.container_registry_private_endpoint_subnet_address_prefix
}
})
}
resource "azurerm_private_dns_zone" "container_registry" {
count = var.use_private_networking && var.container_registry_private_dns_zone_creation_enabled ? 1 : 0
name = "privatelink.azurecr.io"
resource_group_name = local.resource_group_name
tags = var.tags
}
resource "azurerm_private_dns_zone_virtual_network_link" "container_registry" {
count = var.use_private_networking && var.container_registry_private_dns_zone_creation_enabled ? 1 : 0
name = "privatelink.azurecr.io"
private_dns_zone_name = azurerm_private_dns_zone.container_registry[0].name
resource_group_name = local.resource_group_name
virtual_network_id = local.virtual_network_id
tags = var.tags
}
resource "azurerm_public_ip" "this" {
count = var.use_private_networking && var.public_ip_creation_enabled ? 1 : 0
allocation_method = "Static"
location = var.location
name = local.public_ip_name
resource_group_name = local.resource_group_name
sku = "Standard"
tags = var.tags
}
resource "azurerm_nat_gateway" "this" {
count = var.use_private_networking && var.nat_gateway_creation_enabled ? 1 : 0
location = var.location
name = local.nat_gateway_name
resource_group_name = local.resource_group_name
sku_name = "Standard"
tags = var.tags
}
resource "azurerm_nat_gateway_public_ip_association" "this" {
count = var.use_private_networking && var.nat_gateway_creation_enabled ? 1 : 0
nat_gateway_id = azurerm_nat_gateway.this[0].id
public_ip_address_id = local.public_ip_id
}