AWS & Typescript Masterclass - Testing and debugging Lambdas

September 9th, 2022

(28) section intro

(29) CloudWatch logs

(30) using AWS SDK


(30) using AWS SDK

npm i aws-sdk



import {S3} from "aws-sdk";

const s3Client = new S3()


const buckets = await s3Client.listBuckets().promise();


body: 'here are your buckets' + JSON.stringify(buckets.Buckets)



const s3PolicyStatement = new PolicyStatement();


s3PolicyStatement.addResources('*'); // anti-pattern ; use specific!



(31) run lambda locally in debug mode

run config (in VSCode)


"version": "0.2.0",



"type": "node"

"request": "launch"

"name":"Debug local file",

"runtimeArgs":["-r", "ts-node/register"]






(you can add AWS credentials to env if you're not logged in locally)


Run lambda/api-gateway locally from command line

cdk run local lambda with sam-cli

Debug with 1password-credentials from intellij

Debug typescript file with breakpoints (credentials via 1password)