Skip to content

Commit dd218bf

Browse files
committed
Adjust SG of ECS nodes to grant ssh access from VPN
1 parent 4221c98 commit dd218bf

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

_variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,9 @@ variable "fargate_only" {
293293
variable "ec2_key_enabled" {
294294
default = false
295295
description = "Generate a SSH private key and include in launch template of ECS nodes"
296+
}
297+
298+
variable "vpn_cidr" {
299+
default = ["10.37.0.0/16"]
300+
description = "Cidr of VPN to grant ssh access to ECS nodes"
296301
}

sg-ecs-nodes.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ resource "aws_security_group_rule" "all_from_alb_internal_to_ecs_nodes" {
3232
source_security_group_id = aws_security_group.alb_internal[0].id
3333
}
3434

35+
resource "aws_security_group_rule" "ssh_from_vpn_to_ecs_nodes" {
36+
count = var.ec2_key_enabled ? 1 : 0
37+
38+
description = "ssh from VPN"
39+
type = "ingress"
40+
from_port = 22
41+
to_port = 22
42+
protocol = "tcp"
43+
cidr_blocks = var.vpn_cidr
44+
security_group_id = aws_security_group.ecs_nodes.id
45+
}
46+
3547
resource "aws_security_group_rule" "all_from_ecs_nodes_to_ecs_nodes" {
3648
description = "Traffic between ECS nodes"
3749
type = "ingress"

0 commit comments

Comments
 (0)