/yesterdaytabase

Cascade data from production to staging with AWS RDS and Lambda

Primary LanguagePythonApache License 2.0Apache-2.0

Yesterdaytabase

Yesterdaytabase is a Lambda function that pulls previous snapshots of RDS databases for use as staging or testing environments. The function runs on a schedule and recreates the DB with a CloudFormation stack. For more about the internals, see my blog post on it.

Usage

If you only have one database, launch the stack and fill in the SourceConfiguration value with a one-line JSON object. The config is in this format:

{
  "config": {
    "domain": "mysite.com", # the root of your Route53 zone
    "db": {
      "name": "my-rds-dbname",
      "security_group": "sg-12345678",
      "subnet_group": "net-group-12345678" # the RDS subnet group to launch the DB in
    }
  }
}

For more databases, create more CloudWatch Event rules that have the same JSON format in their input field.

Alternatively, you can bake the configuration into a file in the deployed function, called config.json. The format matches the config key in the event above.

Run it

Want to run it? Launch it and go. Launch stack yesterdaytabase Fill in the database you've got snapshots of and your Route53 domain.