alb http listener rules processing fix (#115)

- Added changes to handle additional conditions `host_headers`,
`path_patterns`, `http_request_methods`, `source_ips`, `http_headers`,
and `query_strings`
This commit is contained in:
Jorge Falcon authored and GitHub committed 2025-10-02 21:52:38 -04:00
1 parent 411fc58f1d
commit 8e81115f9b
2 files changed
+43 -5

No files matched your search

+25 -4
View File
@@ -102,10 +102,31 @@ module "alb" {
}
rules = { for idx, rule in var.alb_config.https_listener_rules :
"rule-${idx}" => merge(rule, {
conditions = [for condition in rule.conditions : {
for k, v in condition :
"${trimsuffix(k, "s")}" => { values = v }
}]
conditions = flatten([
for condition in rule.conditions : concat(flatten([
for key in ["host_headers", "http_request_methods", "path_patterns", "source_ips"]:
lookup(condition, key, null) != null ? [{
"${trimsuffix(key, "s")}" = {
values = condition[key]
}
}] : []
]),
lookup(condition, "http_headers", null) != null ? [
for header in condition.http_headers : {
http_header = {
http_header_name = header.http_header_name
values = header.values
}
}]: [],
lookup(condition, "query_strings", null) != null ? [{
query_string = [
for qs in condition.query_strings : {
key = qs.key
value = qs.value
}
]
}]: [],
)])
actions = [for action in rule.actions : merge(action, {
target_group_key = try(action.target_group_key, try("tg-${action.target_group_index}", null))
})]
+18 -1
View File
@@ -73,7 +73,7 @@ locals {
}
module "fleet" {
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.18.2"
source = "github.com/fleetdm/fleet-terraform?depth=1&ref=tf-mod-root-v1.18.3"
certificate_arn = module.acm.acm_certificate_arn
vpc = {
@@ -167,6 +167,23 @@ module "fleet" {
# routing_http_response_x_frame_options_header_value = "SAMEORIGIN"
# }
# Optional rules to allowlist only osquery/orbit traffic and allowed IPs.
# For https_listener_rules, the following conditions are supported
# Example:
# conditions = [{
# host_headers = ["example.com"]
# path_patterns = ["/api/*"]
# http_request_methods = ["GET", "POST"]
# source_ips = ["1.2.3.4/32"]
# http_headers = [{
# http_header_name = "X-Custom-Header-Foo"
# values = ["bar"]
# }]
# query_strings = [{
# key = "env"
# value = "foobar"
# }]
# }]
#
# https_listener_rules = concat([{
# priority = 9000
# actions = [{