Serverless at scale on AWS: three Terraform + Lambda scenarios
AwsSamples is sample code for large-scale web sites on AWS, organised as three self-contained scenarios — each with its own Terraform state, deploy script and README:
- shopping/ — high-scale e-commerce: catalog, cart, checkout, fulfillment on CloudFront + WAF, S3, API Gateway with Cognito JWT auth, Lambda, DynamoDB, SQS + dead-letter queues, Step Functions and EventBridge.
- gaming/ — a realtime game backend: matchmaking, live events, leaderboards and telemetry over API Gateway WebSocket, Lambda, DynamoDB and Kinesis.
- chat/ — large-scale WebSocket chat with SQS fan-out and a browser client.
The mental model every scenario shares
- Stateless compute everywhere. No EC2, no containers — Lambda scales without an operator. Handlers are plain .NET 8.
- Managed data planes. DynamoDB with pay-per-request billing, TTLs and global secondary indexes instead of servers you patch.
- Async by default. SQS queues with DLQs buffer spikes; Step Functions choreograph multi-step flows; EventBridge fans events out.
- One deployable per scenario.
publish.ps1zips the Lambda handlers;terraform applycreates everything else.
Deploying one yourself
cd shopping
./lambdas/publish.ps1 # dotnet publish + zip each handler
cd terraform
terraform init
terraform plan -out plan.tfplan
terraform apply plan.tfplan
Prerequisites are Terraform 1.6+, the .NET 8 SDK and the AWS CLI. outputs.tf
prints the endpoints when it finishes, and terraform destroy removes everything —
which makes this a safe sandbox for learning.
Why single-region on purpose
The samples stay single-region so they stay readable; the README's hardening notes sketch the multi-region path (Route 53 failover, DynamoDB global tables, per-region state). Read the Terraform files top to bottom — they double as an architecture course, the same way the Azure Terraform article does for Microsoft's cloud.
Repository: github.com/bobhuang1/AwsSamples