def event_handler(event, context): # initialise the ddb continuous backup manager backup.init(None) # handle unknown event types if 'detail' not in event or 'requestParameters' not in event[ "detail"] or event['detail'][ 'eventSource'] != 'dynamodb.amazonaws.com': print "Unknown input event type" print event else: if event['detail']['eventName'] == "CreateTable": # resolve the table dynamo_table_name = event["detail"]["requestParameters"][ "tableName"] # configure the table for continuous backup backup.configure_table(dynamo_table_name) elif event['detail']['eventName'] == "DeleteTable": # delete the firehose delivery stream for this table dynamo_table_name = event["detail"]["requestParameters"][ "tableName"] # deprovision table for continuous backup backup.deprovision_table(dynamo_table_name) else: print "Unknown Event %s" % (event['detail']['eventName']) print event
def deprovision_tables(table_list): for x in table_list: try: dynamo_continuous_backup.deprovision_table(x) except Exception as e: print "Exception while deprovisioning table %s" % (x) print e print "Proceeding..."
def event_handler(event, context): if 'detail' in event and 'errorCode' in event['detail']: # anything that comes in with errors is ignored if debug == True: print "Supressing errored API Call - detail: %s:%s" % ( event['detail']['errorCode'], event['detail']['errorMessage']) return # initialise the ddb continuous backup manager backup.init(None) # handle unknown event types if 'detail' not in event or 'requestParameters' not in event[ "detail"] or event['detail'][ 'eventSource'] != 'dynamodb.amazonaws.com': print "Unknown input event type" print event else: if debug == True: print event if event['detail']['eventName'] == "CreateTable": # resolve the table dynamo_table_name = event["detail"]["requestParameters"][ "tableName"] # configure the table for continuous backup backup.configure_table(dynamo_table_name) elif event['detail']['eventName'] == "DeleteTable": # delete the firehose delivery stream for this table dynamo_table_name = event["detail"]["requestParameters"][ "tableName"] # deprovision table for continuous backup backup.deprovision_table(dynamo_table_name) else: print "Unknown Event %s" % (event['detail']['eventName']) print event