|
@@ -1,9 +1,18 @@
|
|
|
+locals {
|
|
|
+ # Redundancy count determines how many redundant paths we have in different AZ's.
|
|
|
+ # 1 is good for testing
|
|
|
+ # 2 is probably good enough for all other cases
|
|
|
+ # length(var.public_subnets) is the max
|
|
|
+ redundancy_count = 1
|
|
|
+ #redundancy_count = length(var.public_subnets)
|
|
|
+}
|
|
|
+
|
|
|
resource "aws_ec2_client_vpn_endpoint" "vpn" {
|
|
|
description = "VPN for Employee Access"
|
|
|
client_cidr_block = "172.16.0.0/22"
|
|
|
- split_tunnel = true
|
|
|
+ split_tunnel = var.split_tunnel
|
|
|
server_certificate_arn = aws_acm_certificate.cert.arn
|
|
|
- self_service_portal = "disabled" # requires a self_service_saml_provider in authentication_options
|
|
|
+ self_service_portal = "enabled" # requires a self_service_saml_provider in authentication_options
|
|
|
|
|
|
# TODO: Specify DNS Servers
|
|
|
dns_servers = var.dns_servers
|
|
@@ -17,6 +26,7 @@ resource "aws_ec2_client_vpn_endpoint" "vpn" {
|
|
|
authentication_options {
|
|
|
type = "federated-authentication"
|
|
|
saml_provider_arn = aws_iam_saml_provider.okta.arn
|
|
|
+ self_service_saml_provider_arn = aws_iam_saml_provider.okta-self-service.arn
|
|
|
}
|
|
|
|
|
|
connection_log_options {
|
|
@@ -32,8 +42,7 @@ resource "aws_ec2_client_vpn_endpoint" "vpn" {
|
|
|
}
|
|
|
|
|
|
resource "aws_ec2_client_vpn_network_association" "vpn_subnets" {
|
|
|
- count = length(var.public_subnets)
|
|
|
- #count = 1 # we don't need the redundancy for now
|
|
|
+ count = local.redundancy_count
|
|
|
|
|
|
client_vpn_endpoint_id = aws_ec2_client_vpn_endpoint.vpn.id
|
|
|
subnet_id = var.public_subnets[count.index]
|
|
@@ -48,8 +57,7 @@ resource "aws_ec2_client_vpn_network_association" "vpn_subnets" {
|
|
|
}
|
|
|
|
|
|
resource "aws_ec2_client_vpn_route" "default" {
|
|
|
- count = length(var.public_subnets)
|
|
|
- #count = 1 # we don't need the redundancy for now
|
|
|
+ count = local.redundancy_count
|
|
|
client_vpn_endpoint_id = aws_ec2_client_vpn_endpoint.vpn.id
|
|
|
destination_cidr_block = "10.0.0.0/8"
|
|
|
target_vpc_subnet_id = aws_ec2_client_vpn_network_association.vpn_subnets[count.index].subnet_id
|