in aws_resource_scan.py [0:0]
def add_to_dictionary(self):
"""Add current resource to the list for future dump to json file."""
try:
if self.operation == 'DescribeLoadBalancers':
container_name = 'LoadBalancerDescriptions'
elif self.operation == 'ListAccessKeys':
container_name = 'AccessKeyMetadata'
else:
container_name = self.operation.replace('Describe', '')
container_name = container_name.replace('List', '')
container_name = container_name.replace('Get', '')
is_found, found_resource_data = self.find_dict_extract(container_name,
self.response)
item_count = 0
if is_found:
for i in found_resource_data:
found_resource = resource_info.copy()
found_resource['Location'] = self.region
found_resource['ResourceType'] = self.service + '/' + container_name
lookup_name = self.service + '.' + container_name
item_count = item_count + 1
tags_found, find_tags = self.find_dict_extract('Tags', i)
if tags_found:
assigned_tags = {}
for t in find_tags:
assigned_tags[t['Key']] = t['Value']
found_resource['Tags'] = assigned_tags
name_found, find_name = self.find_dict_extract(
self.lookup_name_property(lookup_name), i)
if name_found:
found_resource['Name'] = find_name
else:
found_resource['Name'] = lookup_name
_resource_list.append(found_resource)
except Exception as exc:
logging.error(exc)