Skip to content

Commit

Permalink
feat: Make the ALB stickiness configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jbonnier committed Nov 14, 2023
1 parent 9543c88 commit f6e7e11
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ module "ecs_app" {
| <a name="input_alb_alarms_response_time_threshold"></a> [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 |
| <a name="input_alb_arn"></a> [alb\_arn](#input\_alb\_arn) | ARN of the ALB. | `string` | n/a | yes |
| <a name="input_alb_arn_suffix"></a> [alb\_arn\_suffix](#input\_alb\_arn\_suffix) | The ARN suffix of ALB. | `string` | n/a | yes |
| <a name="input_alb_ingress_stickiness_cookie_duration"></a> [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 |
| <a name="input_alb_ingress_stickiness_enabled"></a> [alb\_ingress\_stickiness\_enabled](#input\_alb\_ingress\_stickiness\_enabled) | Boolean to enable / disable `stickiness`. | `bool` | `true` | no |
| <a name="input_alb_ingress_stickiness_type"></a> [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 |
| <a name="input_alb_listeners"></a> [alb\_listeners](#input\_alb\_listeners) | A list of map containing a port and a protocol for all ALB listeners. | <pre>list(object({<br> port = number<br> protocol = string<br> }))</pre> | <pre>[<br> {<br> "port": 80,<br> "protocol": "HTTP"<br> }<br>]</pre> | no |
| <a name="input_alb_security_group_id"></a> [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 |
| <a name="input_aliases"></a> [aliases](#input\_aliases) | List of FQDN's - Used to set the Alternate Domain Names (CNAMEs). | `list(string)` | `[]` | no |
Expand Down
3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit f6e7e11

Please sign in to comment.