Add service-specific web egress rules

This commit is contained in:
2026-11-15 19:46:54 +09:00
parent 12e0a6e35e
commit 181891cd77
6 changed files with 69 additions and 2 deletions
+15
View File
@@ -46,6 +46,21 @@ module "network_public" {
public_tcp_ports = [80, 443]
}
web_egress_service_rules = {
consul_serf_lan = {
description = "Allow Consul Serf LAN gossip to the test service network"
ip_protocol = "udp"
port = 8301
cidr_ipv4 = "203.0.113.0/24"
}
loki_ingest = {
description = "Allow Loki ingest to the test service network"
ip_protocol = "tcp"
port = 3100
cidr_ipv4 = "203.0.113.0/24"
}
}
vyos_network_interface_id = aws_network_interface.route_target.id
vyos_security_group_id = aws_security_group.vyos_source.id
+7 -1
View File
@@ -15,12 +15,18 @@ output "vyos_source_security_group_ids" {
}
output "web_egress_policy_matches" {
value = length(module.network_public.web_egress_rule_specs) == 18 && alltrue([
value = length(module.network_public.web_egress_rule_specs) == 20 && alltrue([
for cidr in ["192.0.2.0/24", "198.51.100.0/24"] :
toset([for rule in values(module.network_public.web_egress_rule_specs) : rule.from_port if rule.cidr_ipv4 == cidr && rule.ip_protocol == "tcp"]) == toset([3000, 3001, 8200, 8300, 8301, 9000, 25090]) &&
toset([for rule in values(module.network_public.web_egress_rule_specs) : rule.from_port if rule.cidr_ipv4 == cidr && rule.ip_protocol == "udp"]) == toset([123])
]) && toset([for rule in values(module.network_public.web_egress_rule_specs) : rule.from_port if rule.cidr_ipv4 == "0.0.0.0/0" && rule.ip_protocol == "tcp"]) == toset([80, 443]) && alltrue([
for rule in values(module.network_public.web_egress_rule_specs) : rule.description != "" && rule.from_port == rule.to_port
]) && toset([
for key, rule in module.network_public.web_egress_rule_specs : "${key}|${rule.ip_protocol}|${rule.from_port}|${rule.cidr_ipv4}"
if startswith(key, "service_")
]) == toset([
"service_consul_serf_lan|udp|8301|203.0.113.0/24",
"service_loki_ingest|tcp|3100|203.0.113.0/24",
])
}
@@ -65,7 +65,7 @@ run "plan_network_group3_osaka" {
assert {
condition = output.web_egress_policy_matches
error_message = "The Osaka test must use the same 18 restricted egress rules as production."
error_message = "The Osaka test must use the same 20-rule restricted egress structure as production."
}
assert {