Code improvements
This commit is contained in:
parent
91b13f998f
commit
2d11e8feb4
@ -694,18 +694,15 @@ class LambdaBackend(BaseBackend):
|
|||||||
queue.lambda_event_source_mappings[esm.function_arn] = esm
|
queue.lambda_event_source_mappings[esm.function_arn] = esm
|
||||||
|
|
||||||
return esm
|
return esm
|
||||||
try:
|
for stream in json.loads(dynamodbstreams_backends[self.region_name].list_streams())['Streams']:
|
||||||
stream = json.loads(dynamodbstreams_backends[self.region_name].describe_stream(spec['EventSourceArn']))
|
if stream['StreamArn'] == spec['EventSourceArn']:
|
||||||
spec.update({'FunctionArn': func.function_arn})
|
spec.update({'FunctionArn': func.function_arn})
|
||||||
esm = EventSourceMapping(spec)
|
esm = EventSourceMapping(spec)
|
||||||
self._event_source_mappings[esm.uuid] = esm
|
self._event_source_mappings[esm.uuid] = esm
|
||||||
table_name = stream['StreamDescription']['TableName']
|
table_name = stream['TableName']
|
||||||
table = dynamodb_backends2[self.region_name].get_table(table_name)
|
table = dynamodb_backends2[self.region_name].get_table(table_name)
|
||||||
table.lambda_event_source_mappings[esm.function_arn] = esm
|
table.lambda_event_source_mappings[esm.function_arn] = esm
|
||||||
|
return esm
|
||||||
return esm
|
|
||||||
except Exception:
|
|
||||||
pass # No DynamoDB stream exists
|
|
||||||
raise RESTError('ResourceNotFoundException', 'Invalid EventSourceArn')
|
raise RESTError('ResourceNotFoundException', 'Invalid EventSourceArn')
|
||||||
|
|
||||||
def publish_function(self, function_name):
|
def publish_function(self, function_name):
|
||||||
@ -832,7 +829,7 @@ class LambdaBackend(BaseBackend):
|
|||||||
'eventName': 'INSERT',
|
'eventName': 'INSERT',
|
||||||
'eventVersion': item.to_json()['eventVersion'],
|
'eventVersion': item.to_json()['eventVersion'],
|
||||||
'eventSource': item.to_json()['eventSource'],
|
'eventSource': item.to_json()['eventSource'],
|
||||||
'awsRegion': 'us-east-1',
|
'awsRegion': self.region_name,
|
||||||
'dynamodb': item.to_json()['dynamodb'],
|
'dynamodb': item.to_json()['dynamodb'],
|
||||||
'eventSourceARN': source} for item in items]}
|
'eventSourceARN': source} for item in items]}
|
||||||
func = self._lambdas.get_arn(function_arn)
|
func = self._lambdas.get_arn(function_arn)
|
||||||
|
Loading…
Reference in New Issue
Block a user