forked from telia-oss/terraform-aws-vpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
32 lines (28 loc) · 1.09 KB
/
main.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
# ------------------------------------------------------------------------------
# Resources
# ------------------------------------------------------------------------------
resource "aws_customer_gateway" "customer-gateway" {
bgp_asn = var.customer_gateway_bgp_asn
ip_address = var.customer_gateway_ip
type = "ipsec.1"
}
resource "aws_vpn_gateway" "vpn-gateway" {
vpc_id = var.vpc_id
tags = var.tags
amazon_side_asn = var.amazon_side_asn
}
resource "aws_vpn_gateway_route_propagation" "public_out" {
route_table_id = var.public_subnets_route_table_id
vpn_gateway_id = aws_vpn_gateway.vpn-gateway.id
}
resource "aws_vpn_gateway_route_propagation" "private_out" {
count = var.private_subnet_count
route_table_id = element(var.private_subnets_route_table_ids, count.index)
vpn_gateway_id = aws_vpn_gateway.vpn-gateway.id
}
resource "aws_vpn_connection" "main" {
customer_gateway_id = aws_customer_gateway.customer-gateway.id
type = "ipsec.1"
vpn_gateway_id = aws_vpn_gateway.vpn-gateway.id
tags = var.tags
}