Skip to content

Commit aef26af

Browse files
committed
fix for group id
1 parent 3140144 commit aef26af

File tree

4 files changed

+29
-32
lines changed

4 files changed

+29
-32
lines changed

_example/example.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,4 @@ module "vpn" {
4949
route_subnet_ids = module.subnets.public_subnet_id
5050
network_cidr = ["0.0.0.0/0"]
5151

52-
type = "federated-authentication"
53-
saml_arn = var.saml_arn
54-
dns_names = [""]
55-
security_group_ids = var.security_group_ids
56-
vpc_id = var.vpc_id
57-
group_ids = var.group_ids
58-
5952
}

_example/variables.tf

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +0,0 @@
1-
2-
variable "security_group_ids" {
3-
type = list(any)
4-
default = ["",""]
5-
6-
}
7-
8-
variable "saml_arn" {
9-
type = string
10-
default = ""
11-
description = "saml_arn that is being used"
12-
}
13-
14-
variable "vpc_id" {
15-
type = string
16-
default = ""
17-
description = "vpc id that is being used"
18-
}
19-
20-
variable "group_ids" {
21-
type = string
22-
default = ""
23-
description = "group that is being used"
24-
}

main.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ resource "aws_ec2_client_vpn_endpoint" "default" {
129129
description = module.labels.id
130130
server_certificate_arn = join("", aws_acm_certificate.server.*.arn)
131131
client_cidr_block = var.cidr_block
132+
security_group_ids = var.security_group_ids
132133
split_tunnel = var.split_tunnel_enable
134+
vpc_id = var.vpc_id
133135

134136
authentication_options {
135137
type = var.type
@@ -151,7 +153,6 @@ resource "aws_ec2_client_vpn_endpoint" "default" {
151153
]
152154
}
153155

154-
155156
}
156157

157158
resource "aws_ec2_client_vpn_network_association" "default" {
@@ -180,6 +181,15 @@ resource "aws_ec2_client_vpn_authorization_rule" "vpn_auth" {
180181
authorize_all_groups = true
181182
}
182183

184+
185+
resource "aws_ec2_client_vpn_authorization_rule" "vpn_group_auth" {
186+
count = length(var.group_ids)
187+
client_vpn_endpoint_id = join("", aws_ec2_client_vpn_endpoint.default.*.id)
188+
target_network_cidr = "0.0.0.0/0"
189+
access_group_id = element(var.group_ids, count.index)
190+
}
191+
192+
183193
resource "aws_ec2_client_vpn_route" "vpn_route" {
184194
count = length(var.route_cidr)
185195
client_vpn_endpoint_id = join("", aws_ec2_client_vpn_endpoint.default.*.id)

variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,21 @@ variable "self_saml_arn" {
119119
description = "The ARN of the IAM SAML identity provider for the self service portal. "
120120
}
121121

122+
123+
variable "security_group_ids" {
124+
type = list(any)
125+
default = []
126+
description = "The IDs of one or more security groups to apply to the target network. You must also specify the ID of the VPC that contains the security groups."
127+
}
128+
129+
variable "vpc_id" {
130+
type = string
131+
default = ""
132+
description = "The ID of the VPC to associate with the Client VPN endpoint. If no security group IDs are specified in the request, the default security group for the VPC is applied."
133+
}
134+
135+
variable "group_ids" {
136+
type = list
137+
default = []
138+
description = "The ID of the group to which the authorization rule grants access."
139+
}

0 commit comments

Comments
 (0)