Configure DynamoDB in Serverless


@jayair, I was using serverless 1.30.3. I just upgraded to 1.31.0.

Same error when running locally. But deployed, it appears to work.


Thanks. You are right this is an issue. This happens because the Ref: option is for CloudFormation and while using it locally Serverless does not have access to that. Here are a couple of ways around it.

  1. You can specify it by referencing directly to the resource file tableName: ${self:resources.0.Resources.NotesTable.Properties.TableName}. Where 0 is the index of the resources specified in your serverless.yml.

  2. Create a custom variable for the table name in your serverless.yml and use that in your DynamoDB resource.

We will probably update the tutorial to go with the second option.


Thanks for getting back to me. I like the option for #2 and will likely implement that. #1 just feels a bit clunky.


Why can we remove the following line from libs/dynamodb-lib.js?

AWS.config.update({ region: "us-east-1" });

Without this line, how do Lambda functions know the region of DynamoDB that we want to connect to?


I need to confirm this but by default the AWS SDK within the Lambda defaults the region to the region of the Lambda.

We are going to remove this line from Part I of the tutorial as well since it is causing some confusion.