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.
An example I'm using
const DataTable = new dynamodb.Table(this, 'Example', {
tableName: 'Example',
partitionKey: {
name: 'id',
type: dynamodb.AttributeType.STRING
},
sortKey: {
name: 'name',
type: dynamodb.AttributeType.STRING
},
pointInTimeRecovery: true,
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST
});
// Backup rules
// https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_backup-readme.html
const backupVault = new backup.BackupVault(this, "ExampleBackupVault", {
backupVaultName: "ExampleBackupVault"
})
const plan = new backup.BackupPlan(this, "ExampleBackupPlan")
plan.addRule(backup.BackupPlanRule.weekly(backupVault))
plan.addRule(backup.BackupPlanRule.monthly5Year(backupVault))
plan.addSelection("ExampleBackupSelection", {
resources: [backup.BackupResource.fromDynamoDbTable(DataTable)]
})