def classic_loadbalancer(function, credentials, unused_resource_count, region_list):
    print('Scanning Classic Load balancers')
    elb_count = 0
    unused_elb_detail = []
    for region in region_list:
        try:
            classic_lb = boto3.client('elb', aws_access_key_id=credentials['access_key'], aws_secret_access_key=credentials['secret_key'], region_name=region)
            paginated_data = []
            elb_paginator = classic_lb.get_paginator('describe_load_balancers')
            for load_balancers in elb_paginator.paginate():
                paginated_data.extend(load_balancers['LoadBalancerDescriptions'])
            for elb_detail in paginated_data:
                instance_health_status = []
                instance_data = classic_lb.describe_instance_health(LoadBalancerName=elb_detail['LoadBalancerName'])['InstanceStates']
                for instance in instance_data:
                    instance_health_status.append(instance['State'])
                if ('InService' not in instance_health_status):
                    unused_elb_detail.append({'ResourceType': 'AWS::ElasticLoadBalancing::LoadBalancer', 'ResourceId': elb_detail['LoadBalancerName'], 'Region': region})
                    elb_count += 1
        except:
            pass
    if elb_count:
        unused_elb_detail = json.loads(json.dumps(unused_elb_detail))
        f = csv.writer(open('./aws_logs/classic_loadbalancer.csv', 'w', newline=''))
        f.writerow(['ResourceType', 'ResourceId', 'Region'])
        for unused_elb_detail in unused_elb_detail:
            f.writerow([unused_elb_detail['ResourceType'], unused_elb_detail['ResourceId'], unused_elb_detail['Region']])
    unused_resource_count[function] = elb_count
def classic_loadbalancer(function, credentials, unused_resource_count, region_list):
    print('Scanning Classic Load balancers')
    elb_count = 0
    unused_elb_detail = []
    for region in region_list:
        try:
            classic_lb = boto3.client('elb', aws_access_key_id=credentials['access_key'], aws_secret_access_key=credentials['secret_key'], region_name=region)
            paginated_data = []
            elb_paginator = classic_lb.get_paginator('describe_load_balancers')
            for load_balancers in elb_paginator.paginate():
                paginated_data.extend(load_balancers['LoadBalancerDescriptions'])
            for elb_detail in paginated_data:
                instance_health_status = []
                instance_data = classic_lb.describe_instance_health(LoadBalancerName=elb_detail['LoadBalancerName'])['InstanceStates']
                for instance in instance_data:
                    instance_health_status.append(instance['State'])
                if ('InService' not in instance_health_status):
                    unused_elb_detail.append({'ResourceType': 'AWS::ElasticLoadBalancing::LoadBalancer', 'ResourceId': elb_detail['LoadBalancerName'], 'Region': region})
                    elb_count += 1
        except:
            pass
    if elb_count:
        unused_elb_detail = json.loads(json.dumps(unused_elb_detail))
        f = csv.writer(open('./aws_logs/classic_loadbalancer.csv', 'w', newline=))
        f.writerow(['ResourceType', 'ResourceId', 'Region'])
        for unused_elb_detail in unused_elb_detail:
            f.writerow([unused_elb_detail['ResourceType'], unused_elb_detail['ResourceId'], unused_elb_detail['Region']])
    unused_resource_count[function] = elb_count