Error: dynamodb put function not working
What's Causing This Error
This error mainly occurs with the AWS JavaScript SDK when the put()
function is used as a promise-based function.
For example, suppose you are executing the put()
in a Lambda function and do not wait for it to finish running. The Lambda function will immediately return a response, but the put()
will not get executed.
Solution - Here's How To Resolve It
To resolve the error, use an async-await approach as shown below.
exports.handler = async (event) => { const obj = { pk: '1', name: "Lakindu" }; const response = { statusCode: 200, body: JSON.stringify(obj), }; var params = { 'TableName':'test-table', 'Item': { ...obj }, }; // await the promise and then await the result, so the function gets invoked. await documentClient.put(params).promise(); return response; };
Other Common DynamoDB Errors (with Solutions)
- dynamodb put item not working
- dynamodb query key condition not supported
- 'dynamodb' object has no attribute 'table'
- an expression attribute name used in the document path is not defined
- Error ValidationException: One or more parameter values were invalid: Type mismatch for key X expected: S actual: M
- missing required key 'key' in params dynamodb
- DynamoDB error cannot find module build/Release/DTraceProviderBindings
- lambda function not triggering from dynamodb
- AWS DynamoDB errors ResourceNotFoundException
- dynamodb: one or more parameter values were invalid: type mismatch for index key
- aws lambda dynamodb nodejs not working after few puts
- ImportError: No module named boto3 (DynamoDB)
- DynamoDB Key element does not match the schema
- DynamoDB ConditionalCheckFailedException
Tired of switching accounts and regions? Use Dynobase.
Try 7-day free trial. No credit card needed.
© 2022 Dynobase