Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toggle to stickiness due to TF/AWS API issues #22

Merged
merged 3 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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