-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
36 lines (34 loc) · 887 Bytes
/
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
33
34
35
36
/**
* AWS VPN Terraform Module
* =====================
*
* Usage:
* ------
*
* module "vpn" {
* source = "../tf_vpn"
*
* add variables
* }
**/
resource "aws_vpn_connection" "vpn" {
vpn_gateway_id = "${var.vpn_gateway_id}"
customer_gateway_id = "${var.customer_gateway_id}"
type = "ipsec.1"
static_routes_only = true
lifecycle {
prevent_destroy = true
}
tags = "${ merge(
var.tags,
map("Name", var.namespaced ?
format("%s-%s-vpn", var.environment, var.name) :
format("%s-vpn", var.name) ),
map("Environment", var.environment),
map("Terraform", "true") )}"
}
resource "aws_vpn_connection_route" "vpn_route" {
count = "${length(var.cidrs)}"
destination_cidr_block = "${element(var.cidrs, count.index)}"
vpn_connection_id = "${aws_vpn_connection.vpn.id}"
}