def get_all_ebs()

in Back-End/lambdas/receive_sqs_message.py [0:0]


def get_all_ebs(account_number, region, cross_account_role):
    
    # Init
    var_list = []

    # Use boto3 on source account
    client_ebs = create_boto_client(
        account_number, region, 'ec2', cross_account_role)

    # Page all elb's
    paginator = client_ebs.get_paginator('describe_volumes')

    for page in paginator.paginate():
        for i in page['Volumes']:

            var_list.append(
                {
                    'EntryType': 'ebs',
                    'Id': str(i['VolumeId']),
                    'State': str(i['State']),
                    'Size': str(i['Size']),
                    'VolumeType': str(i['VolumeType']),
                    'AccountNumber': str(account_number),
                    'Region': str(region),
                    'Tags': str(i.get('Tags', 'No Tag')),
                    'Encrypted': str(i['Encrypted']),
                    'SnapshotId': str(i['SnapshotId']),
                    'AvailabilityZone': str(i['AvailabilityZone']),
                    'CreateTime': str(i['CreateTime'])
                })

    return var_list