File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,12 @@ locals {
104104 )
105105
106106 policies_arn = var. policies_arn != null ? var. policies_arn : [" arn:${ data . aws_partition . current . partition } :iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy" ]
107+
108+ # Chunk these into groups of 5, the limit for IPs in an AWS lb listener
109+ whitelist_unauthenticated_cidr_block_chunks = chunklist (
110+ sort (compact (concat (var. allow_github_webhooks ? var. github_webhooks_cidr_blocks : [], var. whitelist_unauthenticated_cidr_blocks ))),
111+ 5
112+ )
107113}
108114
109115data "aws_partition" "current" {}
@@ -257,10 +263,10 @@ module "alb" {
257263
258264# Forward action for certain CIDR blocks to bypass authentication (eg. GitHub webhooks)
259265resource "aws_lb_listener_rule" "unauthenticated_access_for_cidr_blocks" {
260- count = var. allow_unauthenticated_access ? 1 : 0
266+ count = var. allow_unauthenticated_access ? length (local . whitelist_unauthenticated_cidr_block_chunks ) : 0
261267
262268 listener_arn = module. alb . https_listener_arns [0 ]
263- priority = var. allow_unauthenticated_access_priority
269+ priority = var. allow_unauthenticated_access_priority + count . index
264270
265271 action {
266272 type = " forward"
@@ -269,7 +275,7 @@ resource "aws_lb_listener_rule" "unauthenticated_access_for_cidr_blocks" {
269275
270276 condition {
271277 source_ip {
272- values = sort ( compact ( concat (var . allow_github_webhooks ? var . github_webhooks_cidr_blocks : [], var . whitelist_unauthenticated_cidr_blocks )))
278+ values = local . whitelist_unauthenticated_cidr_block_chunks [ count . index ]
273279 }
274280 }
275281}
You can’t perform that action at this time.
0 commit comments