aws-sts-network-query-tool icon indicating copy to clipboard operation
aws-sts-network-query-tool copied to clipboard

The whole ELB collect failed when an ELB does not have a DNSName

Open CorinneVerheyde opened this issue 1 year ago • 0 comments

On around 600 ELBs, on more than 150 aws accounts, we have 6 ELB without DNSName. This make the script crash when collecting ELB.

$ aws_network_query -elb

--> Fail after several minutes It generate no output file at all, as the program exit on an unexpecting error, whereas it as already collected a lot of ELB configurations.

Here is the error trace :

Traceback (most recent call last):
  File "/home/adm-coverheyde/.local/bin/aws_network_query", line 11, in <module>
    load_entry_point('aws-sts-network-query-tool==1.0.0', 'console_scripts', 'aws_network_query')()
  File "/usr/local/python3/lib/python3.7/site-packages/aws_sts_network_query_tool-1.0.0-py3.7.egg/aws_network_query/app.py", line 504, in main
  File "/usr/local/python3/lib/python3.7/concurrent/futures/_base.py", line 428, in result
    return self.__get_result()
  File "/usr/local/python3/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/local/python3/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/python3/lib/python3.7/site-packages/aws_sts_network_query_tool-1.0.0-py3.7.egg/aws_network_query/app.py", line 422, in worker
  File "/usr/local/python3/lib/python3.7/site-packages/aws_sts_network_query_tool-1.0.0-py3.7.egg/aws_network_query/app.py", line 390, in worker
  File "/usr/local/python3/lib/python3.7/site-packages/aws_sts_network_query_tool-1.0.0-py3.7.egg/aws_network_query/app.py", line 217, in process_load_balancer
KeyError: 'DNSName'

To confirm the issue was coming from the missing DNSName attribute on ELB, I removed the collection of the DNSName (in file aws_network_query/app.py, line 217). The script then finish well and collect all ELB.

216     for item in list:
217         #dict = {'AccountId': account, 'LoadBalancerArn': item['LoadBalancerArn'], 'DNSName': item['DNSName'], 'VpcId': item['VpcId'],'Region': region}
218         dict = {'AccountId': account, 'LoadBalancerArn': item['LoadBalancerArn'], 'VpcId': item['VpcId'],'Region': region}
219         print(f'Account {account}: New Load Balancer found {dict}')

--> Need to add a control if DNSName is not present on ELB ?

CorinneVerheyde avatar May 03 '23 16:05 CorinneVerheyde