Add restricted web egress rules

This commit is contained in:
2026-11-15 08:46:37 +09:00
parent 7eded181e7
commit 16b5332e96
9 changed files with 116 additions and 1 deletions
@@ -39,6 +39,11 @@ run "apply_network_group3_osaka" {
error_message = "All six public ingress rules must reference the created substitute security group."
}
assert {
condition = output.web_egress_policy_matches
error_message = "The Osaka apply test must use the same 18 restricted egress rules as production."
}
assert {
condition = alltrue([
for name in values(output.named_resources) : startswith(name, var.name_prefix)
+6
View File
@@ -40,6 +40,12 @@ module "network_public" {
private_network_b = "198.51.100.0/24"
}
web_egress_policy = {
homelab_tcp_ports = [3000, 3001, 8200, 8300, 8301, 9000, 25090]
homelab_udp_ports = [123]
public_tcp_ports = [80, 443]
}
vyos_network_interface_id = aws_network_interface.route_target.id
vyos_security_group_id = aws_security_group.vyos_source.id
+10
View File
@@ -14,6 +14,16 @@ output "vyos_source_security_group_ids" {
value = module.network_public.vyos_source_security_group_ids
}
output "web_egress_policy_matches" {
value = length(module.network_public.web_egress_rule_specs) == 18 && 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
])
}
output "named_resources" {
value = merge(
module.network_public.named_resource_names,
@@ -1,5 +1,10 @@
provider "aws" {
region = var.region
region = var.region
access_key = "mock_access_key"
secret_key = "mock_secret_key"
skip_credentials_validation = true
skip_metadata_api_check = true
skip_requesting_account_id = true
}
# Flow Logs need pre-existing destinations, including a global IAM role for
@@ -58,6 +63,11 @@ run "plan_network_group3_osaka" {
error_message = "All six public ingress rules must reference the substitute security group."
}
assert {
condition = output.web_egress_policy_matches
error_message = "The Osaka test must use the same 18 restricted egress rules as production."
}
assert {
condition = alltrue([
for name in values(output.named_resources) : startswith(name, var.name_prefix)