Skip to content

Commit 1d2286e

Browse files
authored
fix: block SSH/RDP egress as well (#732)
For consistency, also block SSH and RDP egress from the module.
1 parent cc49913 commit 1d2286e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

vpc/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ No modules.
6464
| [aws_nat_gateway.nat_gw](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/nat_gateway) | resource |
6565
| [aws_network_acl.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl) | resource |
6666
| [aws_network_acl_rule.block_rdp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule) | resource |
67+
| [aws_network_acl_rule.block_rdp_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule) | resource |
6768
| [aws_network_acl_rule.block_ssh](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule) | resource |
69+
| [aws_network_acl_rule.block_ssh_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule) | resource |
6870
| [aws_network_acl_rule.https_request_egress_443](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule) | resource |
6971
| [aws_network_acl_rule.https_request_in_ingress_443](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule) | resource |
7072
| [aws_network_acl_rule.https_request_in_ingress_ephemeral](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule) | resource |

vpc/nacl.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,30 @@ resource "aws_network_acl_rule" "block_rdp" {
3131
to_port = 3389
3232
}
3333

34+
resource "aws_network_acl_rule" "block_ssh_egress" {
35+
count = var.block_ssh ? 1 : 0
36+
network_acl_id = aws_network_acl.main.id
37+
rule_number = 52
38+
egress = true
39+
protocol = "tcp"
40+
rule_action = "deny"
41+
cidr_block = "0.0.0.0/0"
42+
from_port = 22
43+
to_port = 22
44+
}
45+
46+
resource "aws_network_acl_rule" "block_rdp_egress" {
47+
count = var.block_rdp ? 1 : 0
48+
network_acl_id = aws_network_acl.main.id
49+
rule_number = 53
50+
egress = true
51+
protocol = "tcp"
52+
rule_action = "deny"
53+
cidr_block = "0.0.0.0/0"
54+
from_port = 3389
55+
to_port = 3389
56+
}
57+
3458
# Allow an HTTPS request out of the VPC
3559
resource "aws_network_acl_rule" "https_request_egress_443" {
3660
count = var.allow_https_request_out ? 1 : 0

0 commit comments

Comments
 (0)