I deployed a lambda function(functionName) to aws, the function saves data I fetched from a API to DynamoDB.
I can invoke the function: sls invoke local -f functionName and the data save to the db with no problem.
however, when I try to call the deployed function. I am getting this error:
Error saving data to DynamoDB: {“message”:“Missing required key ‘TableName’ in params”,“code”:“MissingRequiredParameter”,“time”:“2018-05-14T05:49:57.600Z”}
please note: the TableName I stored in serverless.yml file:
environment:
DYNAMODB_TABLE: myTable
what is missing from deploy? store myTable in serverless.yml isn’t enough when deploy to aws? but, it did run well when invoke the function at local as you see.
Can you show me the yaml from the Resources section where you are creating the DynamoDB table? The environment var. for the table name should be used there.
This configuration assumes that the Serverless Framework will create and manage the DynamoDB table for you. On deploy it will create the DynamoDB table, and on remove it will destroy it.
If you are connecting to an existing table you will just need to use the SDK and make dynamo calls from your code. No need to add the DynamoDB config in the Resources section. You will still need the IAMRoleStatements to give access to perform operations on the table.
the error code from AWS log isn’t reflect the actual error. I was confused about the error and check many times try to have the missing table name fixed, however, the above script are correct. aws report error, since I have some bugs in my node script. nothing to do with yaml and deplyed handler function.