-
Notifications
You must be signed in to change notification settings - Fork 7
/
r-nat-gateway.tf
48 lines (41 loc) · 1.46 KB
/
r-nat-gateway.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
resource "azurerm_public_ip" "pip" {
count = var.create_public_ip ? 1 : 0
allocation_method = "Static"
location = var.location
name = local.public_ip_name
resource_group_name = var.resource_group_name
zones = var.public_ip_zones
sku = "Standard"
domain_name_label = var.public_ip_domain_name_label
reverse_fqdn = var.public_ip_reverse_fqdn
tags = merge(
local.default_tags,
var.extra_tags
)
}
resource "azurerm_nat_gateway" "natgw" {
location = var.location
name = local.nat_gateway_name
resource_group_name = var.resource_group_name
sku_name = "Standard"
idle_timeout_in_minutes = var.nat_gateway_idle_timeout
tags = merge(
local.default_tags,
var.extra_tags
)
}
resource "azurerm_nat_gateway_public_ip_association" "pip_assoc" {
count = var.create_public_ip ? 1 : 0
nat_gateway_id = azurerm_nat_gateway.natgw.id
public_ip_address_id = azurerm_public_ip.pip[0].id
}
resource "azurerm_nat_gateway_public_ip_association" "pip_assoc_custom_ips" {
for_each = toset(var.public_ip_ids)
nat_gateway_id = azurerm_nat_gateway.natgw.id
public_ip_address_id = each.value
}
resource "azurerm_subnet_nat_gateway_association" "subnet_assoc" {
for_each = toset(var.subnet_ids)
nat_gateway_id = azurerm_nat_gateway.natgw.id
subnet_id = each.value
}