Skip to content

Commit

Permalink
Get associated tags for elbs (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajvb authored Aug 5, 2020
1 parent c8990b2 commit 0ed350e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion aws/elb/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,36 @@ def elbs():
"""
http://botocore.readthedocs.io/en/latest/reference/services/elb.html#ElasticLoadBalancing.Client.describe_load_balancers
"""
return (
elbs = (
botocore_client.get("elb", "describe_load_balancers", [], {})
.extract_key("LoadBalancerDescriptions")
.flatten()
.values()
)

elbs_with_tags = []
for elb in elbs:
tags = (
botocore_client.get(
service_name="elb",
method_name="describe_tags",
call_args=[],
call_kwargs={"LoadBalancerNames": [elb["LoadBalancerName"]]},
regions=[elb["__pytest_meta"]["region"]],
)
.extract_key("TagDescriptions")
.flatten()
.values()
)
# This check is probably unneeded
if len(tags) >= 1:
tags = tags[0]
if "Tags" in tags:
elb["Tags"] = tags["Tags"]
elbs_with_tags.append(elb)

return elbs_with_tags


def elbs_v2():
"""
Expand Down

0 comments on commit 0ed350e

Please sign in to comment.