def elastic_ip(function, credentials, unused_resource_count, region_list):
    print('Scanning Elastic IPs')
    eip_count = 0
    unused_eip_detail = []
    for region in region_list:
        try:
            ec2_client = boto3.client('ec2', aws_access_key_id=credentials['access_key'], aws_secret_access_key=credentials['secret_key'], region_name=region)
            eip_data = ec2_client.describe_addresses()['Addresses']
            for eip in eip_data:
                try:
                    AssociationId = eip['AssociationId']
                except:
                    AssociationId = ''
                if (not AssociationId):
                    unused_eip_detail.append({'ResourceType': 'AWS::EC2::EIP', 'ResourceId': eip['AllocationId'], 'Region': region})
                    eip_count += 1
        except:
            pass
    if eip_count:
        unused_eip_detail = json.loads(json.dumps(unused_eip_detail))
        f = csv.writer(open('./aws_logs/elastic_ip.csv', 'w', newline=''))
        f.writerow(['ResourceType', 'ResourceId', 'Region'])
        for unused_eip_detail in unused_eip_detail:
            f.writerow([unused_eip_detail['ResourceType'], unused_eip_detail['ResourceId'], unused_eip_detail['Region']])
    unused_resource_count[function] = eip_count
def elastic_ip(function, credentials, unused_resource_count, region_list):
    print('Scanning Elastic IPs')
    eip_count = 0
    unused_eip_detail = []
    for region in region_list:
        try:
            ec2_client = boto3.client('ec2', aws_access_key_id=credentials['access_key'], aws_secret_access_key=credentials['secret_key'], region_name=region)
            eip_data = ec2_client.describe_addresses()['Addresses']
            for eip in eip_data:
                try:
                    AssociationId = eip['AssociationId']
                except:
                    AssociationId = 
                if (not AssociationId):
                    unused_eip_detail.append({'ResourceType': 'AWS::EC2::EIP', 'ResourceId': eip['AllocationId'], 'Region': region})
                    eip_count += 1
        except:
            pass
    if eip_count:
        unused_eip_detail = json.loads(json.dumps(unused_eip_detail))
        f = csv.writer(open('./aws_logs/elastic_ip.csv', 'w', newline=))
        f.writerow(['ResourceType', 'ResourceId', 'Region'])
        for unused_eip_detail in unused_eip_detail:
            f.writerow([unused_eip_detail['ResourceType'], unused_eip_detail['ResourceId'], unused_eip_detail['Region']])
    unused_resource_count[function] = eip_count