2

I have dealing with some trouble serverless framework and DynamoDB.

After my lambda function executed, the context.succeed(result) would return the result, but nothing write into the DynamoDB.

Here is the link of demo repo.

I've read this question

And I added the resource to the s-resources-cf.json, then serverless resources deploy again. After sending the request, it still do nothing with DynamoDB.

Here's the thing I've done:

  • Create a table: posts with primary key in specific region

  • Attach AdministratorAccess to my IAM role(I know it's bad to do that.)

  • Add {"Effect": "Allow", "Action": ["*"], "Resource":"arn:aws:dynamodb:${region}:*:table/*"} to the s-resources-cf.json

Do there anything I still misunderstand?

1 Answer 1

2

Your demo repo does not appear to be including the AWS SDK & setting the region as noted in the Getting Started guide. I.e.:

var AWS = require("aws-sdk");
var DOC = require("dynamodb-doc");

AWS.config.update({region: "us-west-1"});
var docClient = new DOC.DynamoDB();

... 

Note that dynamo-doc was deprecated almost a year ago. You may want to try the DynamoDB DocumentClient instead. This updated API has much more clear error-handling semantics that will probably help point out where the problem is.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! But I realize that there has some problem in my handler.js
@Denny what are the problems you have with DynamoDB DocumentClient?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.