File tree Expand file tree Collapse file tree 3 files changed +60
-1
lines changed Expand file tree Collapse file tree 3 files changed +60
-1
lines changed Original file line number Diff line number Diff line change @@ -246,6 +246,35 @@ module "alb" {
246246 }]
247247 }]
248248 },
249+ {
250+ https_listener_index = 0
251+ priority = 4
252+
253+ actions = [{
254+ type = " weighted-forward"
255+ target_groups = [
256+ {
257+ target_group_index = 1
258+ weight = 2
259+ },
260+ {
261+ target_group_index = 0
262+ weight = 1
263+ }
264+ ]
265+ stickiness = {
266+ enabled = true
267+ duration = 3600
268+ }
269+ }]
270+
271+ conditions = [{
272+ query_strings = [{
273+ key = " weighted"
274+ value = " true"
275+ }]
276+ }]
277+ },
249278 {
250279 https_listener_index = 0
251280 priority = 5000
Original file line number Diff line number Diff line change @@ -247,6 +247,37 @@ resource "aws_lb_listener_rule" "https_listener_rule" {
247247 }
248248 }
249249
250+ # weighted forward actions
251+ dynamic "action" {
252+ for_each = [
253+ for action_rule in var . https_listener_rules [count . index ]. actions :
254+ action_rule
255+ if action_rule . type == " weighted-forward"
256+ ]
257+
258+ content {
259+ type = " forward"
260+ forward {
261+ dynamic "target_group" {
262+ for_each = action. value [" target_groups" ]
263+
264+ content {
265+ arn = aws_lb_target_group. main [target_group . value [" target_group_index" ]]. id
266+ weight = target_group. value [" weight" ]
267+ }
268+ }
269+ dynamic "stickiness" {
270+ for_each = [lookup (action. value , " stickiness" , {})]
271+
272+ content {
273+ enabled = try (stickiness. value [" enabled" ], false )
274+ duration = try (stickiness. value [" duration" ], 1 )
275+ }
276+ }
277+ }
278+ }
279+ }
280+
250281 # Path Pattern condition
251282 dynamic "condition" {
252283 for_each = [
Original file line number Diff line number Diff line change @@ -178,7 +178,6 @@ variable "http_tcp_listeners_tags" {
178178 default = {}
179179}
180180
181-
182181variable "security_groups" {
183182 description = " The security groups to attach to the load balancer. e.g. [\" sg-edcd9784\" ,\" sg-edcd9785\" ]"
184183 type = list (string )
You can’t perform that action at this time.
0 commit comments