Connect to existing DynamoDB table

Hi,

Im playing with my 1st service & was wondering how to connect to an existing table instead of having code in the yml file that wants to create a new table every time I deploy.

Ive just received an error message when attempting deploy that says table already exists.

Thanks in advance

Todd

Hey Todd,

If you are connecting to an existing table you will just need to use the SDK and make dynamo calls from your code. Also make sure to provide the function correct IAM access to your existing table like https://github.com/serverless/examples/blob/master/aws-node-rest-api-with-dynamodb/serverless.yml#L10-L19

No need to define the table again in your serverless.yml

Or you can create a new table, migrate the data from existing one into that new table created from serverless.yml resources

2 Likes