Hi folks,
I’ve been following the serverless youtube tutorial trying to get the todos example working. I get stuck at the point where I should be able to create a dynamoDB table and save an item by POSTing to the endpoint. The tutorial sets up a DynamoDB table in the YAML as well as the permissions to use it, and also adds a create handler and script to update the table when the end point is hit using the aws-sdk.
It just isn’t working.
This is the tutorial I’m attempting: https://www.youtube.com/watch?v=sAiAK-DmPbs
When I try and use curl to post some data I am getting {“message”: “Internal server error”}.
Viewing the log gives me:
module initialization error: TypeError
at require (internal/module.js:12:17)
I’ve tried to run it locally using serverless invoke (I’m not sure if this should work or not, I’d expect it to get further than it does). It gives me an errorMessage of “Cannot read property ‘DocumentClient’ of undefined”, errorType “TypeError”.
This seems to say that it’s not instantiating the aws-sdk dynamodb object, but I see no reason why it wouldn’t be? I’ve installed it with npm install --save aws-sdk. I’ve included require(‘aws-sdk’) and have done new AWS.DynamoDb.DocumentClient() (which must not be working).
Please help
Mike