As tech teams grow, simple backend tasks like sending out reminders, tidying up logs, syncing data, resizing images, or grabbing updates from third-party APIs, generate orders or sending some reports can easily turn into little roadblocks.
Traditionally, we might:
- Run a cron job on a server
- Deploy a microservice to handle the task
- Build queues with workers, just for a small function
That’s overkill in many cases.
We needed a cost-effective, event-driven, zero-maintenance solution. Enter AWS Lambda.
In this post, I’ll walk you through:
- Why and when to use Lambda
- How I automated a real task using Lambda + Python
- A step-by-step deployment with actual working code
What is AWS Lambda?
AWS Lambda is a serverless compute service that runs your code in response to events — without you provisioning or managing servers. You upload code, set a trigger, and it runs on-demand.
Highlights:
- Pay per execution
- Auto-scaling and concurrency
- Event-driven: API Gateway, S3, CloudWatch, DynamoDB, etc.
Here is an use case of it.
An external IP lookup — for serverless, it’s easiest to use requests + a free API like ipinfo.io or ip-api.com.
Note: Lambda can’t use requests by default — so you’ll need to bundle it if you use it. Or just use Python’s built-in urllib.
Here I am using a apikey for basic security, you can add more security layer here based on your requirement.
{
"ip": "8.8.8.8",
"apikey":"my-demo-key"
}
Curl Request:
Response:
How to deploy:
Write your code
- Create a Python, Node.js, or other supported language file (e.g. lambda_function.py).
Zip it
- Package your code (and dependencies, if any) into a .zip file.
Create Lambda in AWS Console
- Go to AWS Console → Lambda → Create function.
- Choose “Author from scratch” or “Upload a .zip file”.
Upload your .zip
- Under Code, upload your .zip file.
Set Handler & Runtime
- Example: Handler = lambda_function.lambda_handler
- Runtime = Python 3.x (or your language).
Configure permissions
- Attach an IAM role that gives your Lambda the permissions it needs.
Test it
-
Use the Test button in the Lambda console.
The detailed Demo video is here.
Hope you find it helpful!!!