Skip to content

Commit

Permalink
elb_target_group only set stickiness options when we're using stickin…
Browse files Browse the repository at this point in the history
…ess (ansible-collections#74)

When using UDP AWS will throw an error at you even if stickiness is disabled:
botocore.errorfactory.InvalidConfigurationRequestException: An error occurred (InvalidConfigurationRequest) when calling the ModifyTargetGroupAttributes operation: Stickiness type 'lb_cookie' is not supported for target groups with the UDP protocol
  • Loading branch information
tremble authored May 19, 2020
1 parent d8394e7 commit 21e4f3a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugins/modules/elb_target_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
type: int
stickiness_type:
description:
- The type of sticky sessions. The possible value is lb_cookie.
default: lb_cookie
- The type of sticky sessions.
- 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:
description:
Expand Down Expand Up @@ -547,7 +547,7 @@ def create_or_update_target_group(connection, module):
# Only need to check response code and path for http(s) health checks
if tg['HealthCheckProtocol'] in ['HTTP', 'HTTPS']:
# Health check path
if 'HealthCheckPath'in params and tg['HealthCheckPath'] != params['HealthCheckPath']:
if 'HealthCheckPath' in params and tg['HealthCheckPath'] != params['HealthCheckPath']:
health_check_params['HealthCheckPath'] = params['HealthCheckPath']

# Matcher (successful response codes)
Expand Down Expand Up @@ -744,8 +744,8 @@ def create_or_update_target_group(connection, module):
if stickiness_lb_cookie_duration is not None:
if str(stickiness_lb_cookie_duration) != current_tg_attributes['stickiness_lb_cookie_duration_seconds']:
update_attributes.append({'Key': 'stickiness.lb_cookie.duration_seconds', 'Value': str(stickiness_lb_cookie_duration)})
if stickiness_type is not None and "stickiness_type" in current_tg_attributes:
if stickiness_type != current_tg_attributes['stickiness_type']:
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 update_attributes:
Expand Down Expand Up @@ -825,7 +825,7 @@ def main():
protocol=dict(choices=protocols_list),
purge_tags=dict(default=True, type='bool'),
stickiness_enabled=dict(type='bool'),
stickiness_type=dict(default='lb_cookie'),
stickiness_type=dict(),
stickiness_lb_cookie_duration=dict(type='int'),
state=dict(required=True, choices=['present', 'absent']),
successful_response_codes=dict(),
Expand Down

0 comments on commit 21e4f3a

Please sign in to comment.