diff --git a/README.md b/README.md
index 52bc78b..72ec6cc 100644
--- a/README.md
+++ b/README.md
@@ -297,8 +297,9 @@ Available targets:
| [slow\_start](#input\_slow\_start) | The amount of time for targets to warm up before the load balancer sends them a full share of requests. The range is 30-900 seconds or 0 to disable. The default value is `0` seconds | `number` | `0` | no |
| [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| [stickiness\_cookie\_duration](#input\_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 |
+| [stickiness\_cookie\_name](#input\_stickiness\_cookie\_name) | Name of the application based cookie. AWSALB, AWSALBAPP, and AWSALBTG prefixes are reserved and cannot be used. Only needed when `stickiness_type` is app\_cookie | `string` | `null` | no |
| [stickiness\_enabled](#input\_stickiness\_enabled) | Boolean to enable / disable `stickiness`. Default is `true` | `bool` | `true` | no |
-| [stickiness\_type](#input\_stickiness\_type) | The type of sticky sessions. The only current possible value is `lb_cookie` | `string` | `"lb_cookie"` | no |
+| [stickiness\_type](#input\_stickiness\_type) | The type of sticky sessions. | `string` | `"lb_cookie"` | no |
| [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
| [target\_group\_arn](#input\_target\_group\_arn) | Existing ALB target group ARN. If provided, set `default_target_group_enabled` to `false` to disable creation of the default target group | `string` | `""` | no |
| [target\_type](#input\_target\_type) | The type (`instance`, `ip` or `lambda`) of targets that can be registered with the target group | `string` | `"ip"` | no |
diff --git a/docs/terraform.md b/docs/terraform.md
index 2563536..07fe1dc 100644
--- a/docs/terraform.md
+++ b/docs/terraform.md
@@ -94,8 +94,9 @@
| [slow\_start](#input\_slow\_start) | The amount of time for targets to warm up before the load balancer sends them a full share of requests. The range is 30-900 seconds or 0 to disable. The default value is `0` seconds | `number` | `0` | no |
| [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| [stickiness\_cookie\_duration](#input\_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 |
+| [stickiness\_cookie\_name](#input\_stickiness\_cookie\_name) | Name of the application based cookie. AWSALB, AWSALBAPP, and AWSALBTG prefixes are reserved and cannot be used. Only needed when `stickiness_type` is app\_cookie | `string` | `null` | no |
| [stickiness\_enabled](#input\_stickiness\_enabled) | Boolean to enable / disable `stickiness`. Default is `true` | `bool` | `true` | no |
-| [stickiness\_type](#input\_stickiness\_type) | The type of sticky sessions. The only current possible value is `lb_cookie` | `string` | `"lb_cookie"` | no |
+| [stickiness\_type](#input\_stickiness\_type) | The type of sticky sessions. | `string` | `"lb_cookie"` | no |
| [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
| [target\_group\_arn](#input\_target\_group\_arn) | Existing ALB target group ARN. If provided, set `default_target_group_enabled` to `false` to disable creation of the default target group | `string` | `""` | no |
| [target\_type](#input\_target\_type) | The type (`instance`, `ip` or `lambda`) of targets that can be registered with the target group | `string` | `"ip"` | no |
diff --git a/main.tf b/main.tf
index 93ac4ea..a73b284 100644
--- a/main.tf
+++ b/main.tf
@@ -26,6 +26,7 @@ resource "aws_lb_target_group" "default" {
stickiness {
type = var.stickiness_type
cookie_duration = var.stickiness_cookie_duration
+ cookie_name = var.stickiness_cookie_name
enabled = var.stickiness_enabled
}
diff --git a/variables.tf b/variables.tf
index 4a77aa4..c1774c0 100644
--- a/variables.tf
+++ b/variables.tf
@@ -261,7 +261,12 @@ variable "slow_start" {
variable "stickiness_type" {
type = string
default = "lb_cookie"
- description = "The type of sticky sessions. The only current possible value is `lb_cookie`"
+ description = "The type of sticky sessions."
+
+ validation {
+ condition = contains(["lb_cookie", "app_cookie"], var.stickiness_type)
+ error_message = "The only current possible values are lb_cookie and app_cookie for ALBs"
+ }
}
variable "stickiness_cookie_duration" {
@@ -270,6 +275,12 @@ variable "stickiness_cookie_duration" {
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 "stickiness_cookie_name" {
+ type = string
+ default = null
+ description = "Name of the application based cookie. AWSALB, AWSALBAPP, and AWSALBTG prefixes are reserved and cannot be used. Only needed when `stickiness_type` is app_cookie"
+}
+
variable "stickiness_enabled" {
type = bool
default = true