in Back-End/lambdas/receive_sqs_message.py [0:0]
def compare_and_update_function(account_number, region, sqs_function, cross_account_role):
print('printing event....')
try:
# init
current_boto_list = []
dynamo_list = []
# Get Current Boto Data
if sqs_function == 'lambda':
current_boto_list = get_all_lambda(
account_number, region, cross_account_role)
elif sqs_function == 'ec2':
current_boto_list = get_all_ec2(
account_number, region, cross_account_role)
elif sqs_function == 'lb':
current_boto_list = get_all_load_balancers(
account_number, region, cross_account_role)
elif sqs_function == 'ebs':
current_boto_list = get_all_ebs(
account_number, region, cross_account_role)
elif sqs_function == 'eks':
current_boto_list = get_all_eks(
account_number, region, cross_account_role)
elif sqs_function == 'rds':
current_boto_list = get_all_rds(
account_number, region, cross_account_role)
elif sqs_function == 'iam-roles':
current_boto_list = get_all_iam_roles(
account_number, cross_account_role)
elif sqs_function == 'iam-users':
current_boto_list = get_all_iam_users(
account_number, cross_account_role)
elif sqs_function == 'iam-attached-policys':
current_boto_list = get_all_iam_attached_policys(
account_number, cross_account_role)
elif sqs_function == 'odcr':
current_boto_list = get_all_odcr(
account_number, region, cross_account_role)
elif sqs_function == 'lightsail':
current_boto_list = get_all_lightsail(
account_number, region, cross_account_role)
elif sqs_function == 'org':
current_boto_list = get_organizations(
account_number, region, cross_account_role)
elif sqs_function == 'vpc':
current_boto_list = get_all_vpc(
account_number, region, cross_account_role)
elif sqs_function == 'network-interfaces':
current_boto_list = get_all_network_interfaces(
account_number, region, cross_account_role)
elif sqs_function == 'subnet':
current_boto_list = get_all_subnets(
account_number, region, cross_account_role)
elif sqs_function == 'ri':
current_boto_list = get_all_ris(
account_number, region, cross_account_role)
elif sqs_function == 's3-buckets':
current_boto_list = get_all_s3_buckets(
account_number, cross_account_role)
elif sqs_function == 'org':
current_boto_list = get_organizations(
account_number, region, cross_account_role)
else:
print(f'Invalid function passed: {sqs_function}')
raise ValueError(f'Invalid function passed: {sqs_function}')
if sqs_function == 'org':
dynamo_list = get_current_table(entry_type=sqs_function, region='us-east-1')
# Don't search regions for global API's
elif sqs_function in ['s3-buckets', 'iam-roles', 'iam-users', 'iam-attached-policys']:
dynamo_list = get_current_table(entry_type=sqs_function, account_number=account_number)
else:
dynamo_list = get_current_table(entry_type=sqs_function, region=region, account_number=account_number)
print(f'Comparing: {sqs_function} {account_number} {region} current={len(current_boto_list)} prev={len(dynamo_list)}')
compare_lists_and_update(boto_list=current_boto_list, dynamo_list=dynamo_list)
except ClientError as e:
print(f'Error: {sqs_function} in {account_number} in {region} - {e}')
except Exception as e:
print(f'Error: {sqs_function} in {account_number} in {region} - {e}')