Registry / devops / cdk-rds-sql

cdk-rds-sql

JSON →
library8.0.11jsnpmunverified

cdk-rds-sql v8.0.11 is a CDK construct library for creating databases, schemas, roles, and users on Aurora Serverless v2, RDS clusters/instances, and AWS DSQL clusters. It supports PostgreSQL, MySQL/MariaDB, and DSQL. The construct automatically generates Lambda functions in your VPC to execute SQL statements, handling secret rotation and IAM authentication. It is designed for enterprise use, working in isolated subnets with VPC endpoints. Unlike raw custom resources, it provides typed CDK constructs (Provider, Role, Database, Schema) and integrates with aws-cdk-lib v2.214+. Release cadence follows semantic-release with Angular commit conventions.

npm install cdk-rds-sql
INSTALL
IMPORT
SIG · CDK-RDS-SQL
C
cdk-rds-sql
devopsjavascriptv8.0.11
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Provider
import { Provider } from 'cdk-rds-sql'
const { Provider } = require('cdk-rds-sql')
ESM-only; CDK constructs typically use ESM imports.
Role
import { Role } from 'cdk-rds-sql'
import { Role } from 'cdk-rds-sql/role'
Top-level export; no subpath imports.
Database
import { Database } from 'cdk-rds-sql'
import Database from 'cdk-rds-sql'
Named export, not default.
Schema
import { Schema } from 'cdk-rds-sql'
Available in recent versions for Postgres schemas.

Creates an Aurora Serverless PostgreSQL cluster, a Provider (Lambda), a database, and a role (user) inside it using CDK.

import { App, Stack, Duration, RemovalPolicy } from 'aws-cdk-lib'; import * as ec2 from 'aws-cdk-lib/aws-ec2'; import * as rds from 'aws-cdk-lib/aws-rds'; import { Provider, Role, Database } from 'cdk-rds-sql'; const app = new App(); const stack = new Stack(app, 'TestStack'); const vpc = ec2.Vpc.fromLookup(stack, 'Vpc', { vpcId: stack.node.tryGetContext('vpcId') ?? 'default', }); const cluster = new rds.ServerlessCluster(stack, 'Cluster', { vpc, engine: rds.DatabaseClusterEngine.AURORA_POSTGRESQL, parameterGroup: rds.ParameterGroup.fromParameterGroupName(stack, 'PG', 'default.aurora-postgresql11'), removalPolicy: RemovalPolicy.DESTROY, scaling: { autoPause: Duration.minutes(60), minCapacity: rds.AuroraCapacityUnit.ACU_2, maxCapacity: rds.AuroraCapacityUnit.ACU_2 }, }); const provider = new Provider(stack, 'Provider', { vpc, cluster, secret: cluster.secret!, }); const database = new Database(stack, 'Database', { provider, databaseName: 'mydb', }); const role = new Role(stack, 'Role', { provider, roleName: 'myuser', databaseName: 'mydb', }); app.synth();
Debug
Known issues
breakingVersion 7.x dropped support for CDK v1. Requires aws-cdk-lib >=2.214.0.
fix
Upgrade CDK to v2 and use cdk-rds-sql >=7.0.0.
affects: >=7.0.0
gotchaProvider Lambda must have network access to the RDS cluster's VPC. If using isolated subnets, VPC endpoints for Secrets Manager and KMS are required.
fix
Ensure VPC endpoints (com.amazonaws.region.secretsmanager, com.amazonaws.region.kms) are set up in the VPC.
affects: *
deprecatedThe 'cluster' property on Provider is deprecated in favor of using 'cluster' or 'instance' directly; the old property name 'cluster' still works but may be removed.
fix
Use 'cluster' (same name) but check for deprecation warnings; future versions may require a different property.
affects: <8.0.0
breakingRemoved support for Aurora Serverless v1 (non-v2). You must use ServerlessCluster from aws-rds (v2).
fix
Use rds.ServerlessCluster with engine AURORA_POSTGRESQL or AURORA_MYSQL.
affects: >=8.0.0
gotchaCreating a Role with IAM authentication requires additional IAM policies on the Lambda execution role. Not automatically configured.
fix
Add iam:CreateServiceLinkedRole and appropriate RDS IAM auth actions to the Provider Lambda's role.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'cdk-rds-sql'
Package not installed or using incorrect import path.
fix
Run 'npm install cdk-rds-sql' and use import { Provider } from 'cdk-rds-sql'.
Provider requires a 'secret' property when using a cluster
Missing secret parameter in Provider constructor.
fix
Add 'secret: cluster.secret' to the Provider props.
Subnet 'subnetType' must be specified when using VPC subnet selection
Provider defaults to isolated subnets, but VPC may not have them.
fix
Specify vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS } if needed.
Secret '...' not found in AWS Secrets Manager
Provider Lambda cannot access the secret due to missing VPC endpoint or permissions.
fix
Add a Secrets Manager VPC endpoint and ensure the Lambda has secretsmanager:GetSecretValue permission.
Upgrade
Version history
8.0.11latest on npm
Audit
Dependencies
aws-cdk-librequiredCore CDK library for defining cloud resources
constructsrequiredRequired by aws-cdk-lib
Agent activity
2 hits · last 30 days
node
2
Resources
cdk-rds-sql — npm install cdk-rds-sql · libregistry