https://github.com/awslabs/aws-backup-dynamodb-rotator
The AWS Backup DynamoDB Rotator restores DynamoDB backups to a new timestamped table based on patterns you specify.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.4%) to scientific vocabulary
Repository
The AWS Backup DynamoDB Rotator restores DynamoDB backups to a new timestamped table based on patterns you specify.
Basic Info
- Host: GitHub
- Owner: awslabs
- License: apache-2.0
- Language: Go
- Default Branch: mainline
- Homepage: https://console.aws.amazon.com/lambda/home/create/app?applicationId=arn:aws:serverlessrepo:us-east-1:637093487455:applications/AWS-Backup-DynamoDB-Rotator
- Size: 141 KB
Statistics
- Stars: 9
- Watchers: 2
- Forks: 5
- Open Issues: 2
- Releases: 0
Metadata Files
README.md
AWS Backup DynamoDB Rotator
The AWS Backup DynamoDB Rotator ("the app") restores an Amazon DynamoDB backup to a new timestamped table, allowing you to test your backups and populate reporting, staging, or development environments.
The app subscribes to an Amazon Simple Notification Service (SNS) topic and listens for messages from AWS Backup. When a BACKUP_JOB_COMPLETE event is received, an AWS Step Functions state machine execution begins that restores the backup to a new table. Optionally, once the restore is complete, an AWS Systems Manager (SSM) parameter is updated with the ARN of the newly-restored table.
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS pricing page for details.
bash
.
├── README.MD <-- This README file
├── screenshots <-- Screenshots
└── src <-- source directory for the AWS Lambda functions
│ └── check-restore-status <-- dir for the CheckRestoreStatus Lambda Function
│ │ └── main.go <-- Lambda function, checks the status of the restored DynamoDB table
│ └── restore-backup <-- dir for the RestoreBackup Lambda Function
│ │ └── main.go <-- Lambda function, initiates the restore of the backed up DynamoDB table
│ └── start-workflow <-- dir for the StartWorkflow Lambda Function
│ │ └── main.go <-- Lambda function, initiates the Step Functions state machine if required
│ └── update-ssm-parameter <-- dir for the UpdateSSMParameter Lambda Function
│ │ └── main.go <-- Lambda function, updates the SSM Parameter if provided
├── Makefile <-- Makefile with commands for building the Lambda functions
├── template.yaml <-- SAM template
├── CODE_OF_CONDUCT.md <-- Code of Conduct for contributors to this repository
├── CONTRIBUTING.md <-- Guidelines for submitting changes to this repository
├── LICENSE <-- Apache-2.0 license file
Pre-Requisites
The app requires the following AWS resources to exist before installation:
- An AWS Backup vault configured to send notification events to SNS.
If you are using the Default vault:
bash
aws backup put-backup-vault-notifications \
--backup-vault-name Default \
--sns-topic-arn "arn:aws:sns:{AWS_REGION}:{AWS_ACCOUNT}:{SNS_TOPIC}" \
--backup-vault-events BACKUP_JOB_COMPLETED
- An SNS topic configured to allow notifications from the Backup vault. Include the following JSON in the access policy of the Amazon SNS topic that you use to track AWS Backup events. You must specify the ARN of your topic.
json
{
"Sid": "My-statement-id",
"Effect": "Allow",
"Principal": {
"Service": "backup.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:{AWS_REGION}:{AWS_ACCOUNT}:{SNS_TOPIC}"
}
One or more DynamoDB tables configured in Backup that you wish to restore regularly.
An AWS Backup job in the Backup vault that backs up the DynamoDB tables you wish to restore.
Parameters
BackupSNSTopicARN- [Required] The ARN for a previously existing SNS topic to which AWS Backup publishes its notifications. The Step Function will subscribe to this topic and begin execution when aBACKUP_JOB_COMPLETEDnotification is published.SourcePattern- [Required] A regular expression matching the table name - not full ARN - of resources to be restored, e.g.,(?i)-production$for all DynamoDB tables ending with-production(case insensitive). To match and restore all DynamoDB tables, use the expression.*ReplacementPattern- [Required] A replacement expression used to name the restored resource given in the format, e.g.,-stagingto replace the given SourcePatternParameter with-stagingin the newly restored instance. A date time stamp of the format-20060102-15-04-05 (-YYYYMMDD-HH-mm-ss)will be appended to the replacement name in all cases. To use the original name of the restored resource with the date time stamp appended, use$0as the replacement expression.SSMParameterName- [Optional] The name and path of an AWS Systems Manager (SSM) Parameter Store parameter to be created or updated with the ARN of the newly restored database, e.g.,/staging/database-arn. This is useful for automating reporting, staging, and test database rollover. This parameter is optional, and if no value is provided no parameter will be created or updated.
Instructions
**IMPORTANT NOTE:* Creating this application in your AWS account will create and consume AWS resources, which will cost money. Be sure to shut down/remove all resources once you are finished to avoid ongoing charges to your AWS account (see instructions on cleaning up/tear down below).*
Getting started
To get the AWS Backup DynamoDB Rotator up and running in your own AWS account, follow these steps (if you do not have an AWS account, please see How do I create and activate a new Amazon Web Services account?):
- Go to the AWS Backup DynamoDB Rotator page in the AWS Console. Note: If you are logged in as an IAM user, ensure your account has permissions to create and manage the necessary resources and components for this application.
- Under the Application Settings section, enter values for each of the parameters as described above.
- Ensure that the checkbox next to I acknowledge that this app creates custom IAM roles and resource policies. is selected.
- In the bottom right, choose Deploy. SAR deploys the app into your AWS account.
Cleaning up
To tear down your application and remove all resources associated with the AWS Backup DynamoDB Rotator, follow these steps:
- Log into the Amazon CloudFormation Console and find the stack you created for the demo app.
- Delete the stack.
Remember to shut down/remove all related resources once you are finished to avoid ongoing charges to your AWS account.
How it Works

The app subscribes to an existing SNS topic where AWS Backup publishes its event notifications. When a BACKUPJOBCOMPLETE event is received for a DynamoDB table matching a pattern you specify, an AWS Step Functions state machine execution begins that restores the backup to a new table.
The first Lambda function processes the body of an SNS message sent by AWS Backup to an SNS topic. This lambda function determines whether the resource should be restored using a set of business rules, and if so, initiates an AWS Step Functions state machine using the SDK API call SFN.StartExecution.
AWS Step Functions State Machine
The first state machine passes input to the state machine in the following format:
json
{
"BackupSnsMessage": {
"StatusMessage": { "type": "string" },
"RecoveryPointArn": { "type": "string" },
"BackedUpResourceArn": { "type": "string" },
"BackupJobID": { "type": "string" }
},
"SourcePattern": { "type": "string" },
"ReplacementPattern": { "type": "string" },
"SSMParameterName": { "type": "string" }
}
When invoked, the state machine invokes a second Lambda function which initiates the restore using the SDK API call DynamoDB.RestoreTableFromBackup.
Once the restore is initiated, the state machine checks whether an SSM parameter was defined in the CloudFormation/SAM template. If not, execution completes successfully.
If an SSM parameter was defined, the state machine then sleeps for a pre-determined period before invoking a third Lambda function which checks the status of the restore operation using the SDK API call DynamoDB.DescribeTable.
If the restore is not yet complete, the state machine enters a loop of sleeping and checking the status of the restore operation.
Once the restore is complete, the state machine invokes a fourth Lambda function which updates the provided SSM parameter with the ARN of the newly-restored DynamoDB table using the SDK API call SSM.PutParameter.
Each Lambda function adds its return values to the state in the state machine. On completion, the state is in the following format (top level objects only):
json
{
"BackupSnsMessage": {},
"SourcePattern": "",
"ReplacementPattern": "",
"SSMParameterName": "",
"RestoreTableFromBackupOutput": {},
"DescribeTableOutput": {},
"UpdateSSMParameterOutput": {}
}
Once completed, we have a newly restored copy of our backup named to match the time the backup was started.

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Owner
- Name: Amazon Web Services - Labs
- Login: awslabs
- Kind: organization
- Location: Seattle, WA
- Website: http://amazon.com/aws/
- Repositories: 914
- Profile: https://github.com/awslabs
AWS Labs
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: about 2 years ago
All Time
- Total issues: 1
- Total pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: 6 days
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 2
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- GokulakrishnanP027 (1)
Pull Request Authors
- dependabot[bot] (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- github.com/aws/aws-lambda-go v1.13.2
- github.com/aws/aws-sdk-go v1.33.0
- github.com/BurntSushi/toml v0.3.1
- github.com/aws/aws-lambda-go v1.13.2
- github.com/aws/aws-sdk-go v1.33.0
- github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d
- github.com/davecgh/go-spew v1.1.0
- github.com/go-sql-driver/mysql v1.5.0
- github.com/jmespath/go-jmespath v0.3.0
- github.com/pkg/errors v0.9.1
- github.com/pmezard/go-difflib v1.0.0
- github.com/russross/blackfriday/v2 v2.0.1
- github.com/shurcooL/sanitized_anchor_name v1.0.0
- github.com/stretchr/objx v0.1.0
- github.com/stretchr/testify v1.4.0
- github.com/stretchr/testify v1.5.1
- github.com/urfave/cli v1.22.1
- golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
- golang.org/x/net v0.0.0-20200202094626-16171245cfb2
- golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
- golang.org/x/text v0.3.0
- gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
- gopkg.in/yaml.v2 v2.2.2