I use DynamoDB with nodeJS on a Lambda function using serverless. When I scan item from my local computer it works but when I deploy my function scan does not respond. No errors
const docClient = new AWS.DynamoDB.DocumentClient({
apiVersion: "2012-08-10",
});
const checkApiKey = async (apiKey, ) => {
try {
log.debug("before scan");
let result = await docClient
.scan({
"MY_TABLE",
FilterExpression: "#apiKey = :apiKey",
ExpressionAttributeNames: {
"#apiKey": "apiKey",
},
ExpressionAttributeValues: { ":apiKey": apiKey },
})
.promise();
log.debug("after scan");
} catch (error) {
log.error("Can not get dynamo object", { message: error.message });
throwError(error);
}
};
When I call this function on AWS, I can see in my log before scan
but I don't see after scan
nor error message from catch.
DynamoDB operations like "create" works fine.
I have been looking for a solution for several days ... Without success
I'm not sure if it's causing your problem, but the first thing that stuck out to me is how you are defining the table name in the call to scan:
According to the docs, that should be a key/value pair
If you are using the Serverless Framework, do you get different results if you run the function local vs remote?
For example, running the function locally from the command line:
vs running the function remotely (in AWS) from the command line