Skip to content

Commit

Permalink
Merge pull request ansible-collections#548 from heytrav/elb-target-gr…
Browse files Browse the repository at this point in the history
…oup-app-session

Collect arguments for application session stickiness and update docs

Reviewed-by: https://github.com/apps/ansible-zuul
  • Loading branch information
ansible-zuul[bot] authored Apr 26, 2021
2 parents b7bf67c + c831cc4 commit c87531f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions elb_target_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,22 @@
- 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).
type: int
stickiness_app_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 application-generated cookie is considered stale. The range is 1 second to 1 week (604800 seconds).
type: int
version_added: 1.5.0
stickiness_app_cookie_name:
description:
- The name of the application cookie. Required if I(stickiness_type=app_cookie).
type: str
version_added: 1.5.0
stickiness_type:
description:
- The type of sticky sessions.
- Valid values are C(lb_cookie), C(app_cookie) or C(source_ip).
- If not set AWS will default to C(lb_cookie) for Application Load Balancers or C(source_ip) for Network Load Balancers.
type: str
successful_response_codes:
Expand Down Expand Up @@ -466,6 +479,8 @@ def create_or_update_target_group(connection, module):
stickiness_enabled = module.params.get("stickiness_enabled")
stickiness_lb_cookie_duration = module.params.get("stickiness_lb_cookie_duration")
stickiness_type = module.params.get("stickiness_type")
stickiness_app_cookie_duration = module.params.get("stickiness_app_cookie_duration")
stickiness_app_cookie_name = module.params.get("stickiness_app_cookie_name")

health_option_keys = [
"health_check_path", "health_check_protocol", "health_check_interval", "health_check_timeout",
Expand Down Expand Up @@ -753,6 +768,12 @@ def create_or_update_target_group(connection, module):
if stickiness_type is not None:
if stickiness_type != current_tg_attributes.get('stickiness_type'):
update_attributes.append({'Key': 'stickiness.type', 'Value': stickiness_type})
if stickiness_app_cookie_name is not None:
if stickiness_app_cookie_name != current_tg_attributes.get('stickiness_app_cookie_name'):
update_attributes.append({'Key': 'stickiness.app_cookie.cookie_name', 'Value': str(stickiness_app_cookie_name)})
if stickiness_app_cookie_duration is not None:
if str(stickiness_app_cookie_duration) != current_tg_attributes['stickiness_app_cookie_duration_seconds']:
update_attributes.append({'Key': 'stickiness.app_cookie.duration_seconds', 'Value': str(stickiness_app_cookie_duration)})

if update_attributes:
try:
Expand Down Expand Up @@ -833,6 +854,8 @@ def main():
stickiness_enabled=dict(type='bool'),
stickiness_type=dict(),
stickiness_lb_cookie_duration=dict(type='int'),
stickiness_app_cookie_duration=dict(type='int'),
stickiness_app_cookie_name=dict(),
state=dict(required=True, choices=['present', 'absent']),
successful_response_codes=dict(),
tags=dict(default={}, type='dict'),
Expand Down

0 comments on commit c87531f

Please sign in to comment.