Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Package

on:
workflow_dispatch: {}
push:
branches: ['master']

permissions:
id-token: write
contents: read

jobs:
publish-api:
runs-on: depot-ubuntu-24.04
timeout-minutes: 15
env:
NODE_OPTIONS: '--max_old_space_size=8192'
steps:
- uses: actions/checkout@v5
- uses: jdx/mise-action@v4

- name: Install
working-directory: ./cdk-postgresql
run: |
pnpm install --frozen-lockfile

- name: Build
working-directory: ./cdk-postgresql
run: |
pnpm build

- name: Publish
Comment thread
pascal-botpress marked this conversation as resolved.
uses: botpress/gh-actions/publish-if-not-exists@master
env:
NPM_CONFIG_PROVENANCE: 'false'
with:
path: './cdk-postgresql'
package_manager: pnpm
28 changes: 14 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.1.0
- uses: actions/setup-node@v1
with:
node-version: "16.0.0"
- uses: actions/checkout@v5
- uses: jdx/mise-action@v4
- name: Install
working-directory: ./cdk-postgresql
run: |
yarn
run: pnpm install --frozen-lockfile
- name: Build
working-directory: ./cdk-postgresql
run: |
yarn build
- name: Test
working-directory: ./cdk-postgresql
run: |
yarn test
run: pnpm build
- name: Check
run: pnpm check
- name: Unit tests
run: pnpm --filter @botpress/cdk-postgresql test:unit
- name: Integration tests
run: pnpm --filter @botpress/cdk-postgresql test:integration
- name: Synthesize test stack
run: pnpm --filter myapp synth
env:
STACK_NAME: ci
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpm 11.24.0
nodejs 22.23.2
2 changes: 1 addition & 1 deletion cdk-postgresql/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
*.js
!jest.config.js
!lib/lambda/**/*.ts
*.d.ts
node_modules
dist

# CDK asset staging directory
.cdk.staging
Expand Down
10 changes: 0 additions & 10 deletions cdk-postgresql/.npmignore

This file was deleted.

1 change: 0 additions & 1 deletion cdk-postgresql/.nvmrc

This file was deleted.

2 changes: 1 addition & 1 deletion cdk-postgresql/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Botpress
Copyright (c) 2021-2026 Botpress

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion cdk-postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Installation

`npm install @botpress/cdk-postgresql` or `yarn add @botpress/cdk-postgresql`
`pnpm install @botpress/cdk-postgresql`
Comment thread
pascal-botpress marked this conversation as resolved.

## Usage

Expand Down
7 changes: 0 additions & 7 deletions cdk-postgresql/jest.config.js

This file was deleted.

2 changes: 2 additions & 0 deletions cdk-postgresql/lib/lambda.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface UpdateDatabaseEvent
Owner: string;
};
OldResourceProperties: {
ServiceToken: string;
Connection: Connection;
Name: string;
Owner: string;
Expand Down Expand Up @@ -80,6 +81,7 @@ export interface UpdateRoleEvent
PasswordArn: string;
};
OldResourceProperties: {
ServiceToken: string;
Connection: Connection;
Name: string;
PasswordArn: string;
Expand Down
10 changes: 5 additions & 5 deletions cdk-postgresql/lib/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Construct } from "constructs";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
import * as lambda from "aws-cdk-lib/aws-lambda-nodejs";
import { Runtime } from "aws-cdk-lib/aws-lambda";
import * as logs from "aws-cdk-lib/aws-logs";
import * as iam from "aws-cdk-lib/aws-iam";
import * as cr from "aws-cdk-lib/custom-resources";
Expand Down Expand Up @@ -95,11 +96,10 @@ export class Provider extends Construct implements iam.IGrantable {
const handlerSecurityGroup = vpc
? new ec2.SecurityGroup(this, "HandlerSecurityGroup", { vpc })
: undefined;
const handlerSecurityGroups = handlerSecurityGroup
? [handlerSecurityGroup]
: undefined;
const handlerSecurityGroups = handlerSecurityGroup ? [handlerSecurityGroup] : undefined;
const handler = new lambda.NodejsFunction(scope, "handler", {
entry: path.join(__dirname, "handler.js"),
entry: path.join(__dirname, "..", "dist", "handler.cjs"),
runtime: Runtime.NODEJS_24_X,
bundling: {
nodeModules: ["pg", "pg-format"],
},
Expand All @@ -124,7 +124,7 @@ export class Provider extends Construct implements iam.IGrantable {
handlerSecurityGroup,
ec2.Port.tcp(this.port),
"cdk-postgresql provider",
true
true,
);
}
}
Expand Down
65 changes: 41 additions & 24 deletions cdk-postgresql/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
{
"name": "@botpress/cdk-postgresql",
"version": "2.0.1",
"version": "3.0.0",
"description": "Postgresql constructs for AWS CDK",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "./dist/index.cjs",
"types": "./dist/index.d.cts",
"type": "module",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"files": ["dist"],
"author": {
"name": "Botpress",
"url": "https://github.com/botpress"
Expand All @@ -14,36 +28,39 @@
},
"license": "MIT",
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"test": "AWS_REGION=us-east-1 AWS_ACCESS_KEY_ID=something AWS_SECRET_ACCESS_KEY=something jest"
"build": "pnpm exec tsdown",
"watch": "pnpm exec tsdown -w",
"check": "pnpm run check:type",
"check:type": "pnpm exec tsc --noEmit",
"test": "pnpm run test:unit && pnpm run test:integration",
"test:unit": "pnpm run build && pnpm exec vitest --run --project=unit",
"test:integration": "pnpm exec vitest --run --project=integration",
"prepublishOnly": "pnpm run build"
},
"peerDependencies": {
"aws-cdk-lib": "^2.2.0",
"constructs": "^10.0.0"
"aws-cdk-lib": "^2.239.0",
"constructs": "^10.3.0"
},
"dependencies": {
"@aws-sdk/client-secrets-manager": "3.47.2",
"@types/aws-lambda": "^8.10.92",
"@types/node": "17.0.8",
"esbuild": "^0.14.12",
"pg": "8.7.1",
"@aws-sdk/client-secrets-manager": "3.1116.0",
"pg": "8.23.0",
"pg-format": "1.0.4",
"verror": "^1.10.1"
},
"devDependencies": {
"@types/jest": "^27.4.0",
"@types/ms": "^0.7.31",
"@types/pg": "8.6.4",
"@types/pg-format": "1.0.2",
"@types/verror": "^1.10.5",
"aws-cdk-lib": "^2.2.0",
"constructs": "^10.0.0",
"@types/aws-lambda": "^8.10.162",
"@types/node": "22.13.14",
"@types/ms": "^2.1.0",
"@types/pg": "8.23.0",
"@types/pg-format": "1.0.5",
"@types/verror": "^1.10.11",
"aws-cdk-lib": "^2.266.0",
"constructs": "^10.8.1",
"eslint": "6.2.0",
"jest": "^27.4.7",
"ms": "^2.1.3",
"testcontainers": "^8.2.0",
"ts-jest": "^27.1.3",
"typescript": "4.5.4"
"testcontainers": "^12.1.0",
"tsdown": "^0.22.14",
"typescript": "^5.9.3",
"vitest": "^4.1.11"
}
}
23 changes: 7 additions & 16 deletions cdk-postgresql/test/constructs.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { test } from "@jest/globals";
import { test, describe } from "vitest";
import { Template } from "aws-cdk-lib/assertions";
import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
import * as cdk from "aws-cdk-lib";
import { Construct } from "constructs";
import { Database, Role, Provider } from "../lib";

class TestStack extends cdk.Stack {
readonly exportPrefix: string;
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id);
super(scope, id, props);
}
}

const getLogicalId = (construct: Construct) =>
cdk.Stack.of(construct).getLogicalId(
construct.node.defaultChild as cdk.CfnElement
);
cdk.Stack.of(construct).getLogicalId(construct.node.defaultChild as cdk.CfnElement);

describe("database", () => {
test("has correct props", () => {
Expand Down Expand Up @@ -93,7 +90,7 @@ describe("database", () => {
// but only 3 Functions:
// * 1 for the DB handler (created by us)
// * 1 for the DB provider (created by us)
// * 1 for the LogRetention (created by the CDK))
// * 1 for the LogRetention (created by the CDK)
template.resourceCountIs("AWS::Lambda::Function", 3);
});
});
Expand All @@ -103,10 +100,7 @@ describe("role", () => {
const app = new cdk.App();
const stack = new TestStack(app, "Stack");

const connectionPassword = new secretsmanager.Secret(
stack,
"ConnectionPassword"
);
const connectionPassword = new secretsmanager.Secret(stack, "ConnectionPassword");
const rolePassword = new secretsmanager.Secret(stack, "RolePassword");

const host = "somedb.com";
Expand Down Expand Up @@ -148,10 +142,7 @@ describe("role", () => {
const app = new cdk.App();
const stack = new TestStack(app, "Stack");

const connectionPassword = new secretsmanager.Secret(
stack,
"ConnectionPassword"
);
const connectionPassword = new secretsmanager.Secret(stack, "ConnectionPassword");
const rolePassword = new secretsmanager.Secret(stack, "RolePassword");

const host = "somedb.com";
Expand Down Expand Up @@ -181,7 +172,7 @@ describe("role", () => {
// but only 3 Functions:
// * 1 for the Role handler (created by us)
// * 1 for the Role provider (created by us)
// * 1 for the LogRetention (created by the CDK))
// * 1 for the LogRetention (created by the CDK)
template.resourceCountIs("AWS::Lambda::Function", 3);
});
});
Loading