@cloudsnorkel/cdk-rds-sanitized-snapshots

中文文档
0.1.6发布于 2026/02/03Apache-2.0TypeScriptCommonJS零依赖构建来源已验证近 30 天下载 5845

CDK construct to periodically take snapshots of RDS databases, sanitize them, and share with selected accounts.

原始使用文档
文档目录6 节
  1. Overview
  2. Usage
  3. Code Sample
  4. Encryption
  5. Troubleshooting
  6. Testing

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

版本与发布记录

@cloudsnorkel/cdk-rds-sanitized-snapshots 共发布 11 个版本,首次发布于 2022/07/11;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.6latest2026/02/039 个月前
0.1.52025/07/031.4 年前
0.1.42025/05/071.5 年前
0.1.32024/10/012 年前
0.1.22024/09/072 年前
0.1.12024/04/262 年前

关于 @cloudsnorkel/cdk-rds-sanitized-snapshots 的常见问题

@cloudsnorkel/cdk-rds-sanitized-snapshots 是什么?

CDK construct to periodically take snapshots of RDS databases, sanitize them, and share with selected accounts.

如何安装 @cloudsnorkel/cdk-rds-sanitized-snapshots?

在项目目录运行 npm install @cloudsnorkel/cdk-rds-sanitized-snapshots,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:aws-cdk-lib(^2.146.0)、constructs(^10.0.5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cloudsnorkel/cdk-rds-sanitized-snapshots 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cloudsnorkel/cdk-rds-sanitized-snapshots 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cloudsnorkel/cdk-rds-sanitized-snapshots 可以商用吗?

@cloudsnorkel/cdk-rds-sanitized-snapshots 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cloudsnorkel/cdk-rds-sanitized-snapshots 的下载量有多少?

根据 npm 官方下载统计,@cloudsnorkel/cdk-rds-sanitized-snapshots 在 2026/10/10 – 2026/11/08 这 30 天内被下载 5,845 次,日均约 195 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cloudsnorkel/cdk-rds-sanitized-snapshots 还在维护吗?

最新版本 0.1.6 发布于 2026/02/03(9 个月前);至今共发布 11 个版本,其中过去 12 个月发布了 1 个;首次发布于 2022/07/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。