Skip to content

Commit a53bedf

Browse files
committed
Add enable_internet_access var and VPN route
1 parent 613fb06 commit a53bedf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ resource aws_ec2_client_vpn_authorization_rule ingress-all {
5959
description = "Allow all VPN groups access to ${var.allowed_ingress_network_cidr}"
6060
}
6161

62+
resource aws_ec2_client_vpn_route internet-access {
63+
count = var.enable_internet_access ? 1 : 0
64+
for_each = toset(var.subnet_ids)
65+
client_vpn_endpoint_id = aws_ec2_client_vpn_endpoint.default.id
66+
destination_cidr_block = "0.0.0.0/0"
67+
target_vpc_subnet_id = aws_ec2_client_vpn_network_association.default[each.key].subnet_id
68+
}
69+
6270
data "aws_region" "current" {}
6371

6472
# 'Borrowed' from: https://github.com/achuchulev/terraform-aws-client-vpn-endpoint/blob/master/main.tf

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ variable "security_groups" {
2222
default = null
2323
}
2424

25+
variable "enable_internet_access" {
26+
type = bool
27+
description = "If true, add a route to 0.0.0.0/0 on VPN endpoint route table. Your VPN subnet must also have a route to an Internet Gateway."
28+
default = false
29+
}
30+
2531
// Authentication
2632

2733
variable "cert_dir" {

0 commit comments

Comments
 (0)