From f6e7e115516586e6c51c7b53d6dead61945d8124 Mon Sep 17 00:00:00 2001 From: jbonnier Date: Tue, 14 Nov 2023 10:40:32 -0500 Subject: [PATCH] feat: Make the ALB stickiness configurable --- README.md | 3 +++ main.tf | 3 +++ variables.tf | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/README.md b/README.md index a864e1a..46c9e24 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,9 @@ module "ecs_app" { | [alb\_alarms\_response\_time\_threshold](#input\_alb\_alarms\_response\_time\_threshold) | The maximum average target response time (in seconds) over a period. A negative value will disable the alert. | `number` | `0.5` | no | | [alb\_arn](#input\_alb\_arn) | ARN of the ALB. | `string` | n/a | yes | | [alb\_arn\_suffix](#input\_alb\_arn\_suffix) | The ARN suffix of ALB. | `string` | n/a | yes | +| [alb\_ingress\_stickiness\_cookie\_duration](#input\_alb\_ingress\_stickiness\_cookie\_duration) | The time period, in seconds, during which requests from a client should be routed to the same target. After this time period expires, the load balancer-generated cookie is considered stale. The range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds) | `number` | `86400` | no | +| [alb\_ingress\_stickiness\_enabled](#input\_alb\_ingress\_stickiness\_enabled) | Boolean to enable / disable `stickiness`. | `bool` | `true` | no | +| [alb\_ingress\_stickiness\_type](#input\_alb\_ingress\_stickiness\_type) | The type of sticky sessions. The only current possible value is `lb_cookie` | `string` | `"lb_cookie"` | no | | [alb\_listeners](#input\_alb\_listeners) | A list of map containing a port and a protocol for all ALB listeners. |
list(object({
port = number
protocol = string
}))
|
[
{
"port": 80,
"protocol": "HTTP"
}
]
| no | | [alb\_security\_group\_id](#input\_alb\_security\_group\_id) | ALB security group id (to allow connection from the ALB to the service). | `string` | n/a | yes | | [aliases](#input\_aliases) | List of FQDN's - Used to set the Alternate Domain Names (CNAMEs). | `list(string)` | `[]` | no | diff --git a/main.tf b/main.tf index c8dcfd3..da91900 100644 --- a/main.tf +++ b/main.tf @@ -33,6 +33,9 @@ module "alb_ingress" { health_check_protocol = var.service_container_protocol default_target_group_enabled = true health_check_matcher = var.health_check_matcher + stickiness_type = var.alb_ingress_stickiness_type + stickiness_cookie_duration = var.alb_ingress_stickiness_cookie_duration + stickiness_enabled = var.alb_ingress_stickiness_enabled context = module.this.context attributes = concat(module.this.attributes, [lower(var.service_container_protocol), var.service_container_port]) diff --git a/variables.tf b/variables.tf index dae30c0..f38652f 100644 --- a/variables.tf +++ b/variables.tf @@ -141,6 +141,24 @@ variable "alb_security_group_id" { description = "ALB security group id (to allow connection from the ALB to the service)." } +variable "alb_ingress_stickiness_type" { + type = string + default = "lb_cookie" + description = "The type of sticky sessions. The only current possible value is `lb_cookie`" +} + +variable "alb_ingress_stickiness_cookie_duration" { + type = number + default = 86400 + description = "The time period, in seconds, during which requests from a client should be routed to the same target. After this time period expires, the load balancer-generated cookie is considered stale. The range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds)" +} + +variable "alb_ingress_stickiness_enabled" { + type = bool + default = true + description = "Boolean to enable / disable `stickiness`." +} + variable "ecs_cluster_name" { type = string description = "The name of the ECS cluster."