Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply table name #257

Open
wants to merge 1 commit into
base: v1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ class ServerlessDynamodbLocal {
const resources = _.get(stack, "Resources", []);
return Object.keys(resources).map((key) => {
if (resources[key].Type === "AWS::DynamoDB::Table") {
if (!resources[key].Properties.TableName) {
const service = this.service.service;
const stage = this.options.stage || this.service.provider.stage;
resources[key].Properties.TableName = `${service}-${stage}-${key}`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By adding the service name to the TableName it can pretty easily reach the 256 char max length that DynamoDB has for its name. What about limiting the name to stage-key?

Suggested change
resources[key].Properties.TableName = `${service}-${stage}-${key}`;
resources[key].Properties.TableName = `${stage}-${key}`;

}
return resources[key].Properties;
}
}).filter((n) => n);
Expand Down