in chalice/deploy/planner.py [0:0]
def _plan_dynamodbeventsource(self, resource):
# type: (models.DynamoDBEventSource) -> Sequence[InstructionMsg]
uuid_varname = '%s_uuid' % resource.resource_name
function_arn = Variable(
'%s_lambda_arn' % resource.lambda_function.resource_name
)
instructions = [] # type: List[InstructionMsg]
if self._remote_state.resource_exists(resource):
deployed = self._remote_state.resource_deployed_values(resource)
uuid = deployed['event_uuid']
return instructions + [
models.APICall(
method_name='update_lambda_event_source',
params={'event_uuid': uuid,
'batch_size': resource.batch_size,
'maximum_batching_window_in_seconds':
resource.maximum_batching_window_in_seconds}
)
] + self._batch_record_resource(
'dynamodb_event', resource.resource_name, {
'stream_arn': deployed['stream_arn'],
'event_uuid': deployed['event_uuid'],
'lambda_arn': deployed['lambda_arn'],
}
)
return instructions + [
(models.APICall(
method_name='create_lambda_event_source',
params={'event_source_arn': resource.stream_arn,
'batch_size': resource.batch_size,
'function_name': function_arn,
'starting_position': resource.starting_position,
'maximum_batching_window_in_seconds':
resource.maximum_batching_window_in_seconds},
output_var=uuid_varname,
), 'Subscribing %s to DynamoDB stream %s\n'
% (resource.lambda_function.function_name,
resource.stream_arn))
] + self._batch_record_resource(
'dynamodb_event', resource.resource_name, {
'stream_arn': resource.stream_arn,
'event_uuid': Variable(uuid_varname),
'lambda_arn': function_arn,
}
)