Skip to content

Commit

Permalink
Merge pull request #22 from rackspace-infrastructure-automation/stick…
Browse files Browse the repository at this point in the history
…y-issues

Add toggle to stickiness due to TF/AWS API issues
  • Loading branch information
John Titus authored Oct 26, 2020
2 parents 37891b3 + cf12ec8 commit 04bac20
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
14 changes: 11 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,17 @@ resource "aws_lb_target_group" "tg" {
"instance",
)

stickiness {
type = "lb_cookie"
enabled = false
dynamic "stickiness" {
for_each = lookup(
var.tg_map[element(local.tg_keys, count.index)],
"stickiness_placeholder",
false,
) ? toset(["build"]) : toset([])

content {
enabled = false
type = "lb_cookie"
}
}

health_check {
Expand Down
15 changes: 8 additions & 7 deletions tests/test1/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ module "external" {

tg_map = {
listener1 = {
dereg_delay = 300
port = 80
target_type = "instance"
dereg_delay = 300
port = 80
target_type = "instance"
stickiness_placeholder = true
}
}

Expand Down Expand Up @@ -200,9 +201,10 @@ module "internal" {

tg_map = {
listener1 = {
dereg_delay = 300
port = 80
target_type = "instance"
dereg_delay = 300
port = 80
target_type = "instance"
stickiness_placeholder = true
}
}

Expand Down Expand Up @@ -233,4 +235,3 @@ module "asg" {
module.internal.target_group_arns,
)
}

2 changes: 2 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ tg_map = {
"target_type" = "instance"
}
}
N.B. if you receive an error `Network Load Balancers do not support Stickiness` then try adding a key to your problem target groups of `stickiness_placeholder = true`
*/
variable "tg_map" {
description = "target group map"
Expand Down

0 comments on commit 04bac20

Please sign in to comment.