npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cdk-drizzle-migrate

v2.0.0

Published

AWS CDK construct for running Drizzle ORM migrations

Readme

About

This CDK construct library makes it possible to run the drizzle migrate at deploy of your stack time against the RDS or DSQL cluster of your choice. The supported engines are PostgreSQL, MariaDB and MySQL.

This construct library is intended to be used in enterprise environments, and works in isolated subnets.

Requirements

This package assumes you deploy from a unix shell with access to cp, mkdir, and curl.

Installation

 npm i cdk-drizzle-migrate

You probably will be very unhappy if you don't have esbuild, so as usual in a cdk typescript project make sure that is installed too:

npm i esbuild

And obviously drizzle-kit and drizzle-orm should be available if you actually want to create migrations.

Usage

RDS and Aurora

Have an RDS database and a secret that stores your db credentials. Usually this will be the root secret for your RDS database:

import { DrizzleMigrate } from "@berenddeboer/cdk-drizzle-migrate"

// Create the DrizzleMigrate construct
const migrator = new DrizzleMigrate(this, "DrizzleMigration", {
  dbSecret: database.secret!,
  migrationsPath: "migrations",
  vpc: vpc,
  vpcSubnets: {
    subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
  },
  cluster: database, // Pass the database instance to allow automatic security group configuration
})

Your secret should look like the standard one created by CDK:

{
  "password": "some-password",
  "dbname": "testdb",
  "engine": "postgres",
  "port": 5432,
  "dbInstanceIdentifier": "some-name",
  "host": "some-name.cvabql2flhit.us-east-1.rds.amazonaws.com",
  "username": "postgres"
}

DSQL

For DSQL there is no secret where credentials are stored. Only IAM access is supported.

Drizzle doesn't really support DSQL, so if you create migrations you will often need to tweak them manually as so little of postgresql is supported.

Migrations

Specify the path where the migrations are stored, migrations in this case.

When this resource is deployed, it will run drizzle-kit migrate for you in the lambda.

The default timeout is 5 minutes, you need to increase this if your migration takes more time.

Passing your database cluster is optional. If supplied, the lambda's security group will be added as allowed source to the database security group if no security group is present in handlerProps.securityGroups.

If you do not pass a cluster, make sure to pass in a security group in handlerProps.securityGroups which can connect to your database.

Also if you do not pass a cluster, but you still want to create a database, you may wish to add a dependency to make sure the database is created, before the migration is run:

migrator.resource.node.addDependency(cluster)

Potential pitfalls

  1. The lambda can only run for 15 minutes. If your migrations take longer, this solution will not work.

Working on this code

  1. Install packages: npm ci

  2. Bootstrap CDK if not done: npx cdk bootstrap aws://123456/us-east-1. Replace 123456 with your AWS account.

Handler notes

When making changes to the Lambda handler code in lambda/index.ts, you need to transpile it to JavaScript:

npx projen build:handler

This will generate src/handler/handler.js which is used by the CDK construct.

This technique is used to avoid having to bundle nodejs dependencies as that doesn't work well in this case.