UNPKG

cdk-drizzle-migrate

Version:

AWS CDK construct for running Drizzle ORM migrations

59 lines (58 loc) 2.12 kB
import { CustomResource } from "aws-cdk-lib"; import * as ec2 from "aws-cdk-lib/aws-ec2"; import { NodejsFunction, NodejsFunctionProps } from "aws-cdk-lib/aws-lambda-nodejs"; import * as rds from "aws-cdk-lib/aws-rds"; import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager"; import { Construct } from "constructs"; /** * Properties for DrizzleMigrate */ export interface DrizzleMigrateProps { /** * The database secret containing connection details * Must contain standard CDK database secret properties: username, password, host, port, engine, etc. */ readonly dbSecret: secretsmanager.ISecret; /** * The path to the migrations directory * This directory will be bundled with the Lambda function */ readonly migrationsPath: string; /** * Optional properties to customize the Lambda function * Excludes runtime, entry, and handler which are managed by the construct * @default - Default Lambda configuration is used */ readonly handlerProps?: NodejsFunctionProps; /** * The VPC where the Lambda function will be deployed * Required to allow the Lambda function to connect to the database */ readonly vpc: ec2.IVpc; /** * Optional subnet selection to deploy the Lambda function * @default - PRIVATE_WITH_EGRESS subnets */ readonly vpcSubnets?: ec2.SubnetSelection; /** * Optional database cluster or instance * If provided and a new security group is created, the security group will be * configured to allow access to the database * @default - No database connection is configured */ readonly cluster?: rds.IDatabaseCluster | rds.IDatabaseInstance; } /** * A custom resource that runs Drizzle migrations */ export declare class DrizzleMigrate extends Construct { /** * The custom resource that was created */ readonly resource: CustomResource; /** * The Lambda function that executes the migrations */ readonly handler: NodejsFunction; constructor(scope: Construct, id: string, props: DrizzleMigrateProps); }