Skip to content

Commit

Permalink
AWS ELB: Return empty list when no load balancer name was found
Browse files Browse the repository at this point in the history
When trying to describe a LoadBalancer that doesn't exist, the module crash. Instead of that behavior, this commit will return an empty list when no load balancer is found, allowing to deal next tasks by reading the output of the module.
  • Loading branch information
pjrm committed Aug 31, 2020
1 parent 315f546 commit 1e256fd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/modules/elb_classic_lb_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@
@AWSRetry.backoff(tries=5, delay=5, backoff=2.0)
def list_elbs(connection, names):
paginator = connection.get_paginator('describe_load_balancers')
load_balancers = paginator.paginate(LoadBalancerNames=names).build_full_result().get('LoadBalancerDescriptions', [])
try:
load_balancers = \
paginator.paginate(LoadBalancerNames=names).build_full_result().get('LoadBalancerDescriptions', [])
except is_boto3_error_code('LoadBalancerNotFound'):
return []

results = []

for lb in load_balancers:
Expand Down

0 comments on commit 1e256fd

Please sign in to comment.