serverless-plugin-offline-dynamodb-stream
serverless-plugin-offline-dynamodb-stream copied to clipboard
Python Support?
I'm wondering if this plugin support Python functions or not, because it's seems not working in my project (Python based)
Ok, it works but I think the log for the function is not working, I'll figure out how I can solve it
@alhazmy13 can you please share your serverless.yaml file? I cannot seem to figure out how to call Python lambdas with this plugin's config.
If I do
custom:
dynamodbStream:
host: localhost
port: 8000
region: us-east-2
pollForever: boolean
streams:
- table: roomTable
functions:
- readstream
with handler as a function in stream.py:
functions:
readstream:
handler: stream.handler
environment:
foo: bar
events:
- stream:
enabled: true
type: dynamodb
batchSize: 1
startingPosition: LATEST
arn:
Fn::GetAtt: [roomTable, StreamArn]
I get this error:
DynamoDBStreamReadable error... terminating stream... Error => Error: Cannot find module '/home/fn/serverless-dev/stream'
Error --------------------------------------------------
Error: Cannot find module '/home/fn/serverless-dev/stream'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.resolve (internal/modules/cjs/helpers.js:33:19)
[...]
If I change the custom section to say instead
streams:
- table: roomTable
functions:
- stream.handler
I get this exception:
DynamoDBStreamReadable error... terminating stream... Error => TypeError: Cannot read property 'environment' of undefined
Type Error ---------------------------------------------
TypeError: Cannot read property 'environment' of undefined
at createHandler (/home/fn/serverless-dev/node_modules/serverless-plugin-offline-dynamodb-stream/src/executeFunctions.js:17:51)
at Promise.all.map (/home/fn/serverless-dev/node_modules/serverless-plugin-offline-dynamodb-stream/src/executeFunctions.js:45:23)
@fariedt any updates or follow-ups on this? I got same error when i try to use serverless-plugin-offline-dynamodb-stream and python offline lambda function.
Hi @vlade11115 after too many tests, I found this plugin is not working at all with Python even if there's no error, the invocation is buggy
Similar problem here: I'm trying to run Python function on new events in DynamoDB, execution triggers the following exception:
Error: Cannot find module '/home/mcopik/project/aws/writer'
Require stack:
- /home/mcopik/project/node_modules/serverless-plugin-offline-dynamodb-stream/src/executeFunctions.js
- /home/mcopik/project/node_modules/serverless-plugin-offline-dynamodb-stream/src/FunctionExecutable.js
- /home/mcopik/project/node_modules/serverless-plugin-offline-dynamodb-stream/src/index.js
- /home/mcopik/project/node_modules/serverless/lib/classes/PluginManager.js
- /home/mcopik/project/node_modules/serverless/lib/Serverless.js
- /home/mcopik/project/python-venv/lib/node_modules/serverless/lib/Serverless.js
- /home/mcopik/project/python-venv/lib/node_modules/serverless/scripts/serverless.js
- /home/mcopik/project/python-venv/lib/node_modules/serverless/bin/serverless.js
The configuration looks like this:
custom:
serverless-offline:
host: 0.0.0.0
port: 4000
dontPrintOutput: false
dynamodb:
start:
port: 8000
migrate: true
noStart: false
stages:
- ${self:provider.stage}
dynamodbStream:
host: localhost
port: 8000
region: localhost
streams:
- table: ${self:provider.environment.DYNAMODB_TABLE}-write-queue
functions:
- writer
functions:
writer:
handler: aws/writer.handler
However, looking at the source code I can find only support for Node.js modules?
not working with python as in january 2021!