Skip to main content

CDK Construct for RDS Sanitized Snapshots

NPM PyPI Maven Central Go Nuget Release License

Periodically take snapshots of RDS databases, sanitize them, and share with selected accounts.

Use this to automate your development and/or QA database creation, instead of forcing them to use a database that was created last year and was kind of kept in shape by random acts of kindness. Developers and QA love real data and this lets you create non-production databases with sanitized production data. Use the sanitization step to delete passwords, remove credit card numbers, eliminate PII, etc.

See Constructs Hub for installation instructions and API in all supported languages.

Overview

Architecture diagram

This project supplies a CDK construct that sets up a step function and a timer to execute this function. The function will create a sanitized snapshot of a given database and share it with configured accounts. Those accounts can then create new databases from those snapshots.

The step function does the following to create the snapshot:

  1. Get a snapshot of the given database by either:

    • Finding the latest snapshot for the given database
    • Creating and waiting for a new fresh snapshot
  2. Re-encrypt snapshot if KMS key is supplied

  3. Create a temporary database from the snapshot

  4. Wait for the database to be ready

  5. Reset the master password on the temporary database to a random password

  6. Wait for the password to be set

  7. Use a Fargate task to connect to the temporary database and run configured SQL statements to sanitize the data

  8. Take a snapshot of the temporary database

  9. Optionally share the snapshot with other accounts (if you have separate accounts for developers/QA)

  10. Delete temporary database and snapshot

Usage

  1. Confirm you're using CDK v2

  2. Install the appropriate package

    1. Python

      pip install cloudsnorkel.cdk-rds-sanitized-snapshots
      
    2. TypeScript or JavaScript

      npm i @cloudsnorkel/cdk-rds-sanitized-snapshots
      
    3. Java

      <dependency>
      <groupId>com.cloudsnorkel</groupId>
      <artifactId>cdk.rds.sanitized-snapshots</artifactId>
      </dependency>
      
    4. Go

      go get github.com/CloudSnorkel/cdk-rds-sanitized-snapshots-go/cloudsnorkelcdkrdssanitizedsnapshots
      
    5. .NET

      dotnet add package CloudSnorkel.Cdk.Rds.SanitizedSnapshots
      
  3. Use RdsSanitizedSnapshotter construct in your code (starting with default arguments is fine)

Code Sample

let vpc: ec2.Vpc;
let databaseInstance: rds.DatabaseInstance;

new RdsSanitizedSnapshotter(this, 'Snapshotter', {
  vpc: vpc,
  databaseInstance: databaseInstance,
  script: 'USE mydb; UPDATE users SET ssn = \'0000000000\'',
})

Encryption

The new snapshot will be encrypted with the same key used by the original database. If the original database wasn't encrypted, the snapshot won't be encrypted either. To add another step that changes the key, use the KMS key parameter.

See AWS documentation for instructions on giving other accounts access to the key.

Troubleshooting

  • Check the status of the state machine for the step function. Click on the failed step and check out the input, output and exception.

Testing

npm run bundle && npm run integ:default:deploy

Metadata

Release files for cloudsnorkel.cdk-rds-sanitized-snapshots 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cloudsnorkel.cdk-rds-sanitized-snapshots 0.1.6
File Size Uploaded
cloudsnorkel_cdk_rds_sanitized_snapshots-0.1.6.tar.gz 96.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cloudsnorkel.cdk-rds-sanitized-snapshots 0.1.6
File Interpreter ABI Platform
cloudsnorkel_cdk_rds_sanitized_snapshots-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 191.3 kB

Release files / cloudsnorkel_cdk_rds_sanitized_snapshots-0.1.6.tar.gz

Download URL cloudsnorkel_cdk_rds_sanitized_snapshots-0.1.6.tar.gz
Size 96.2 kB
Tags Source
SHA-256 checksum
How to use checksums
049918ef9166ef5a057cbf628d3cc44360cd7bf8e876fa0247a2d6573e1a575d
BLAKE2b-256 checksum
How to use checksums
f7aceb378b88604d08e478a0dc8133b391d3cb9fe4bb306a341cb16349eb1cf7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.14.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

Release files / cloudsnorkel_cdk_rds_sanitized_snapshots-0.1.6-py3-none-any.whl

Download URL cloudsnorkel_cdk_rds_sanitized_snapshots-0.1.6-py3-none-any.whl
Size 95.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
247069e47872b0539f8f12907b5dc065e910b2e22e41b7e5e38f4ed718dea016
BLAKE2b-256 checksum
How to use checksums
028ae027d19bcedaceaa988e18b4878cce10cf7108493385c8322626366e1b84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.14.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page