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
+21
View File
@@ -123,6 +123,27 @@ variable "web_egress_policy" {
}
}
variable "web_egress_service_rules" {
description = "Additional public-web egress rules for services on a single explicit destination CIDR."
type = map(object({
description = string
ip_protocol = string
port = number
cidr_ipv4 = string
}))
validation {
condition = alltrue([
for rule in values(var.web_egress_service_rules) :
contains(["tcp", "udp"], rule.ip_protocol) &&
rule.port >= 1 && rule.port <= 65535 && rule.port == floor(rule.port) &&
trimspace(rule.description) != "" &&
can(cidrnetmask(rule.cidr_ipv4))
])
error_message = "Every service egress rule must have a description, TCP or UDP protocol, an integer port from 1 through 65535, and a valid IPv4 CIDR."
}
}
variable "web_instance" {
description = "Existing public web EC2 instance. user_data is intentionally absent."
type = object({