AWS Builder Center

My First AWS Serverless App: 3 Lessons Learned

To escape "tutorial hell," I built a serverless visitor counter for my portfolio. Here is the architecture I used and the hurdles I tripped over along the way.

The Architecture Amazon S3: Hosted the static HTML/JS frontend.
Amazon API Gateway: Routed HTTP requests from the browser.
AWS Lambda: Ran the Python script to increment the count.
Amazon DynamoDB: Stored the total visitor number.
3 Lessons Learned the Hard Way
  1. IAM Least Privilege is Non-Negotiable When Lambda couldn't reach DynamoDB, I was tempted to slap AmazonDynamoDBFullAccess on it and move on. Don't do this. I took the time to write a custom inline policy granting only dynamodb:UpdateItem and dynamodb:GetItem to my specific table's ARN. Learn IAM early; it is the foundation of AWS security.
  1. CORS Will Haunt Your API I deployed API Gateway, hooked it up to my frontend, and... nothing. The browser blocked the request because the API and website were on different domains. Always configure your CORS headers in API Gateway before testing browser-facing endpoints.
  1. Serverless is Cheap (With Budgets) My biggest fear was a surprise bill. Before writing code, I created a Zero Spend Alert in AWS Budgets. Thanks to the AWS Free Tier, the total cost for my S3 storage, Lambda invocations, and DynamoDB operations was exactly $0.00.
What's Next? I am tearing this down and rebuilding it using the AWS CDK to learn Infrastructure as Code. What was the first thing you built on AWS? Let me know below!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article