I want to create a DynamoDB table and backup using AWS Typescript CDK. Creating DynamoDB using CDK is pretty straightforward, but implementing backup is not easy. Could anyone help me to implement a backup using CDK? I tried to solve this problem, but not enough references on the internet. I would appreciate it if anyone could provide a full example of this scenario. Thanks in advance.
I tried using thishttps://aws-cdk.com/aws-backup/, but not really helpful.
4
Answers
You can provision a back up table – ie, set up the resource.
But CDK does not actually do anything by itself in the cloud. It only generates Cloudformation templates that it passes on to Cloudformation, and that service stands up resources for you. If you want something to run and back up your table to another table or a csv file in an s3 bucket or something, you need to use an AWS Lambda for example, to do this for you after the table is set up.
The link you posted is not actually using CDK to do the backup, its using CDK to set up the AWS Backup service, which will do the backups for you.
It might help if you clarify what backup you need. DynamoDB comes with Point-In-Time-Restore (PITR) backup feature, which you can easily enable via CDK. It gives you ability to restore table to any second within last 35 days. If you need a longer backup, then I would recommend using AWS Backup service which enables scheduled backups. You can easily configure it via CDK as per documentation.
you can use the below code to use DynamoDB table with on-demand backup this one on python
An example I’m using