This document contains detailed reproduction steps for recreating the project structure. This is for internal use and not intended for customers following along with the talk.
This chapter sets up the base infrastructure that should be deployed before the talk begins.
Setup time: ~5 minutes (including ~1 min CDK deploy)
- Lambda function named
reinvent-dat401with a simple greeter handler - Database connection module using
pglibrary (placeholder, no DSQL auth yet)
Note: The DSQL cluster will be created during Chapter 01.
These are the exact commands used to create the starter-kit:
# Create directory structure
mkdir -p starter-kit/lambda/src
cd starter-kit/lambda
# Initialize npm project
npm init -y
# Install dependencies
npm install pg @aws-sdk/dsql-signer
# Install dev dependencies
npm install -D @types/node @types/aws-lambda @types/pg typescript
# Create TypeScript config
npx tsc --init \
--target ES2022 \
--module commonjs \
--lib ES2022 \
--outDir ./dist \
--rootDir ./src \
--strict \
--esModuleInterop \
--skipLibCheck \
--forceConsistentCasingInFileNames \
--resolveJsonModule \
--moduleResolution nodeAdd build scripts to lambda/package.json:
{
"scripts": {
"build": "tsc",
"clean": "rm -rf dist"
}
}# Go to starter-kit root
cd ..
# Create and initialize CDK app
mkdir cdk
cd cdk
npx cdk init app --language typescript
# Install esbuild for bundling (avoids Docker requirement)
npm install --save-dev esbuildEdit lib/cdk-stack.ts to create the Lambda function with name reinvent-dat401.
Edit bin/cdk.ts to rename the stack to ReinventDat401Stack.
See the actual files in this directory for the complete implementation.
From the starter-kit/cdk directory:
# Bootstrap CDK (only needed once per account and region)
npx cdk bootstrap
# Deploy the stack (~1 minute)
npx cdk deployCloudFormation stack name: ReinventDat401Stack
aws lambda invoke \
--function-name reinvent-dat401 \
--cli-binary-format raw-in-base64-out \
--payload '{"name":"reinvent"}' \
/tmp/response.json
cat /tmp/response.json
# Expected: {"greeting":"hello reinvent"}starter-kit/
├── lambda/
│ ├── package.json
│ ├── tsconfig.json
│ └── src/
│ ├── index.ts # Lambda handler (greeter only)
│ └── db.ts # Connection module (pg Pool, no DSQL auth)
└── cdk/
├── bin/
│ └── cdk.ts # CDK app entry
├── lib/
│ └── cdk-stack.ts # Stack definition (Lambda only)
├── cdk.json
├── package.json
└── tsconfig.json
- The
db.tsfile intentionally does NOT include DSQL authentication yet - This will be added during Chapter 01 of the talk
- The Lambda function currently only returns a greeting, not database operations