Dynamodb point-in-time restore

We use DynamoDB and Lambda. If I understand correctly, when you use DynamoDB point-in-time recovery you have to restore to a new db table in the AWS console. Then you have to re-deploy your lambda functions to configure them to use the new table. We’re trying to find a serverles.yml example of how to do this because we keep running into ‘table already exists’ error when trying to update our lambda functions to use the new table that was created when we did a restore from the AWS console.

What may work better is to deploy first to use the new table before restoring. That way there is no existing table.

Thanks for the reply. The problem is DynamoDB point-in-time restore will not let you restore to an existing table, you have to create a new one when you restore. So if we created the table before the restore, we could use point-in-time restore to restore data to the table we created for the deploy.

We followed the guidelines in the serverless-stack.com tutorial when setting up our .yml files. When you update this .yml to use the restored table is when you get the error. This tutorial also has a section on enabling point-in-time restore but it doesn’t cover how to actually do a restore and update your lambda functions to use the new table that gets created when you do a restore.

I believe what may work is having the lambda functions use an environment variable that is set to the new table. we can update the environment variable in the .yml files then deploy and shouldn’t encounter the ‘table already exists’ error.

The “old” way is to use AWS Data Pipeline.

It should be able to restore to an existing table. It requires more effort and it is slower. But it might just solve your problem.

In theory.

  • Run the restore to a new table
  • Dump the table with Data Pipeline to S3
  • Import the content from S3 to the existing table

Never done this myself. So I try it out on a safe environment first.

Thanks for the reply. The environment variable approach worked. For anyone that is interested, a DynamoDB point-in-time restore does restores to a new table. If you have a bunch of lambda functions that use DynamoDB, you need to update them so that they use the restored table. To do this, you can set an environment variable in the provider section of your serverless.yml file to the name of the new table created during the restore and have your lambda functions use the environment variable to determine which table to access. DynamoDB Point-in-time Recovery is a great feature to enable on your DynamoDB tables. Just a little tricky to get your lambda functions using restored tables in the event that you actually have to do a restore.