-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgateways.tf
79 lines (62 loc) · 1.82 KB
/
gateways.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
###################################################
# Internet Gateway
###################################################
# INFO: Not supported attributes
# - `vpc_id`
resource "aws_internet_gateway" "this" {
count = var.internet_gateway.enabled ? 1 : 0
tags = merge(
{
"Name" = coalesce(var.internet_gateway.name, local.metadata.name)
},
local.module_tags,
var.tags,
)
}
resource "aws_internet_gateway_attachment" "this" {
count = var.internet_gateway.enabled ? 1 : 0
vpc_id = aws_vpc.this.id
internet_gateway_id = aws_internet_gateway.this[0].id
}
###################################################
# Egress Only Internet Gateway (IPv6)
###################################################
resource "aws_egress_only_internet_gateway" "this" {
count = var.egress_only_internet_gateway.enabled ? 1 : 0
vpc_id = aws_vpc.this.id
tags = merge(
{
"Name" = coalesce(var.egress_only_internet_gateway.name, local.metadata.name)
},
local.module_tags,
var.tags,
)
lifecycle {
precondition {
condition = local.ipv6_enabled
error_message = "Egress Only Internet Gateway (IPv6) cannot be enabled if IPv6 is not enabled."
}
}
}
###################################################
# Virtual Private Gateway
###################################################
# INFO: Not supported attributes
# - `vpc_id`
# - `availability_zone`
resource "aws_vpn_gateway" "this" {
count = var.vpn_gateway.enabled ? 1 : 0
amazon_side_asn = var.vpn_gateway.asn
tags = merge(
{
"Name" = coalesce(var.vpn_gateway.name, local.metadata.name)
},
local.module_tags,
var.tags,
)
}
resource "aws_vpn_gateway_attachment" "this" {
count = var.vpn_gateway.enabled ? 1 : 0
vpc_id = aws_vpc.this.id
vpn_gateway_id = aws_vpn_gateway.this[0].id
}