This project demonstrates a simple serverless API using AWS Lambda, API Gateway, DynamoDB, CloudFormation, and Budget alerting.
template.yaml– CloudFormation template to deploy infrastructureindex.py– Python Lambda function to handle GET, POST, DELETE for /notes
-
Register in AWS if you haven't already: AWS Free Tier. Documentation: doc.
-
Go to AWS Console → CloudFormation → Create stack → "Choose an existing template (standard)"
-
Upload the
template.yamlfile (Don't forget to change the email in the template to your own seeAddressfor theBudgetresource) -
Click through steps and create the stack (use default options)
-
Wait for the stack to be created (it may take a few minutes)
-
Once the stack is created, you will see a new API Gateway named
NoteApi, a Lambda function namedNoteApiFunction, a DynamoDB table namedNotes, an IAM role for Lambda function namedNoteApiLambdaExecutionRole, and a Budget alert configured. You can check the corresponding resources in the AWS Console.⚠️ Important: The Budget alert will be created with a $1 monthly threshold. Replace the email in the template with your own before deployment.
- Go to AWS Console → Lambda → find function named
NoteApiFunction - Replace the existing code in the Code Editor with the contents of
index.py - Click Deploy
- Go to API Gateway →
NoteApi→ Stages →default - Copy the Invoke URL, e.g.,
https://abc123.execute-api.us-east-1.amazonaws.com/default - Test the API using the
ServerlessWebinar.postman_collection.jsonfor Postman (don't forget to override API_URL variable) or examples below
# Create a note
curl -X POST -d '{"text": "Hello World"}' -H "Content-Type: application/json" https://<invoke-url>/notes
# Get all notes
curl https://<invoke-url>/notes
# Delete a note
curl -X DELETE https://<invoke-url>/notes/<note-id>To avoid charges:
- Delete the CloudFormation stack after the demo
- Remove notes from DynamoDB manually if needed
- The project uses AWS Free Tier–friendly options (Lambda, DynamoDB on-demand, API Gateway)
- Budget notifications are sent via email when usage exceeds 80% of $1
You can ask your instructor or AWS documentation for: