Understanding AWS Pricing
AWS charges for what you use. For Lambda + API Gateway, here’s what costs money.
Lambda Pricing
Free tier (always free):
- 1 million requests per month
- 400,000 GB-seconds of compute time per month
After free tier:
- $0.20 per 1 million requests
- $0.0000166667 per GB-second
What is a GB-second? Memory (GB) × execution time (seconds).
Example:
- Function uses 512 MB (0.5 GB)
- Runs for 200ms (0.2 seconds)
- Cost: 0.5 GB × 0.2 seconds = 0.1 GB-second
For 1 million requests:
- 0.1 GB-second × 1,000,000 = 100,000 GB-seconds
- Within free tier (400,000 GB-seconds limit)
For small projects: You’ll likely stay in the free tier.
API Gateway Pricing
HTTP API (what we used):
- Free tier: First 1 million requests per month
- After: $1.00 per 1 million requests
REST API (older, more features):
- Free tier: First 1 million requests per month
- After: $3.50 per 1 million requests
Data transfer:
- First 1 GB per month free
- After: $0.09 per GB
For small projects: You’ll likely stay in the free tier.
Real-World Cost Example
Scenario: Your API gets 10,000 requests per month.
Lambda:
- Requests: 10,000 (free)
- Compute: ~5,000 GB-seconds (free)
- Cost: $0
API Gateway:
- Requests: 10,000 (free)
- Data transfer: ~100 MB (free)
- Cost: $0
Total: $0 (within free tier)
If you get 2 million requests:
- Lambda: 1M free + 1M × $0.20 = $0.20
- API Gateway: 1M free + 1M × $1.00 = $1.00
- Total: $1.20
Still very cheap.
Why Serverless is Cheap for Small Projects
Traditional server (EC2):
- $7.20/month minimum (even with 0 requests)
- You pay for 24/7 uptime
Serverless (Lambda + API Gateway):
- $0 for low traffic (free tier)
- Pay only when used
Break-even point: Around 1-2 million requests per month. Below that, serverless is cheaper.
Understanding What You Might Be Billed For
Lambda:
- Requests (after free tier)
- Compute time (after free tier)
- Data transfer out (usually free for small amounts)
API Gateway:
- Requests (after free tier)
- Data transfer (after free tier)
Other services (if you add them):
- CloudWatch Logs: First 5 GB free, then $0.50/GB
- DynamoDB: Free tier available
- S3: Free tier available
For this tutorial: Everything should be free (within free tier).
Cleanup Checklist
When you’re done experimenting, clean up to avoid unexpected charges.
Step 1: Delete API Gateway
- Go to API Gateway
- Select your API
- Click “Actions” → “Delete”
- Confirm deletion
Why: API Gateway itself doesn’t cost much, but it’s good practice to clean up.
Step 2: Delete Lambda Function
- Go to Lambda
- Select your function
- Click “Actions” → “Delete”
- Confirm deletion
Why: Lambda is free for low usage, but delete if you’re not using it.
Step 3: Delete CloudWatch Log Groups
- Go to CloudWatch → Log groups
- Find
/aws/lambda/notes-api(or your function name) - Select it
- Click “Actions” → “Delete log group”
- Confirm
Why: Logs cost money after the free tier (5 GB). Delete old logs.
Step 4: Verify No Charges
- Go to AWS Billing Dashboard
- Check “Current charges”
- Should be $0 (within free tier)
Note: AWS bills monthly. Check again next month to be sure.
Responsible Cloud Use
Best practices:
- Delete resources when done experimenting
- Set up billing alerts (get notified if charges exceed threshold)
- Use free tier when possible
- Monitor usage in AWS Cost Explorer
Billing alerts:
- Go to AWS Billing → Preferences
- Enable “Receive Billing Alerts”
- Go to CloudWatch → Alarms
- Create billing alarm (e.g., alert if charges > $5)
What If You Want to Keep It Running?
If you want to keep your API running:
Option 1: Keep it as-is
- Monitor usage
- Stay within free tier
- Delete if you stop using it
Option 2: Add monitoring
- Set up CloudWatch alarms
- Monitor request count
- Get alerts if usage spikes
Option 3: Add a database
- Use DynamoDB (free tier available)
- Store notes persistently
- Still likely free for small projects
Key Takeaways
Before the final summary:
- Lambda + API Gateway are cheap - Free tier covers most small projects
- Pay per use - Only pay when code runs
- Clean up when done - Delete functions, APIs, and logs
- Monitor usage - Set up billing alerts
- Free tier is generous - 1M requests/month for Lambda, 1M for API Gateway
What’s Next?
In the final page, we’ll summarize what you learned and suggest next steps for building on this foundation.