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 throughput error
- dynamodb can not resolve withkeyconditionexpression
- DynamoDB Scan Not Working
- DynamoDB Mapper Could Not Instantiate Class
- ExpressionAttributeValues contains invalid value: One or more parameter values were invalid: An AttributeValue may not contain an empty string
- comparison operator does not return all attributes dynamodb
- dynamodb put item not working
- ProvisionedThroughputExceededException DynamoDB
- 'dynamodb' object has no attribute 'table'
- DynamoDB Update Not Working
- cognitoidentitycredentials is not authorized to perform dynamodb describetable
- dynamodb cannot pickle '\_thread.lock' object
- DynamoDB Delete Not Working
- dynamodb local shell not working
Tired of AWS Console? Try Dynobase.
First 7 days are. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2023 Dynobase