This mini-project demonstrates how to connect an AWS Lambda function to an S3 bucket using a custom, reusable IAM execution role with AWS CDK (TypeScript).
You’ll see:
- How to create an S3 bucket with a unique name.
- How to create a Lambda function (Node.js) that reads from S3.
- How to create a custom IAM role, grant it S3 and CloudWatch permissions, and assign it to the Lambda.
- How to output key resource names for easy CLI use or debugging.
- S3 Bucket: Stores analytics data. Name includes account & region for uniqueness.
- Lambda Function: Reads from the bucket. Uses Node.js and environment variable for the bucket name.
- IAM Role: Reusable execution role with all permissions Lambda needs (logs + S3 read).
- Node.js 18+
- AWS CLI configured
- AWS CDK v2 installed (
npm i -g aws-cdk) - Permissions to deploy resources (S3, Lambda, IAM)
npm install
npm run build