"Wait — you're telling me I can run backend code without servers, setup, or infrastructure?"
Yup. That’s the magic of AWS Lambda — and you don’t need to be a DevOps ninja to get started.
In this beginner-friendly guide, we’ll walk through how to create, test, and run your first Lambda function step-by-step. No EC2. No containers. Just code + click = 🚀
🧠 What is AWS Lambda (in Plain English)?
AWS Lambda is serverless computing — which means you write code, upload it, and AWS runs it for you only when needed.
💡 Real-life analogy: Think of Lambda as a vending machine. You put in the code (your snack), and it serves it only when someone requests it — no kitchen, no chef, no electricity bill unless it’s used.
You don’t manage servers, worry about scaling, or pay when it's idle. It's perfect for microtasks, APIs, or automating workflows.
🎯 What You'll Build
We'll build a simple Lambda function that:
- Takes a name as input
- Returns a greeting like:
"Hello, Dev! 👋"
You can trigger it manually or hook it into an API later.
🚀 Step-by-Step: Create Your First Lambda Function
1. Head to the AWS Lambda Console
https://console.aws.amazon.com/lambda
Click “Create Function”.
2. Choose "Author from scratch"
-
Function name:
helloLambda
-
Runtime:
Node.js 18.x
(or choose Python 3.11 if you prefer) - Permissions: Create a new role with basic Lambda permissions
Click “Create Function”.
✍️ Step 3: Write the Code
In the Function code editor, replace everything with:
exports.handler = async (event) => {
const name = event.name || "Dev";
const response = {
statusCode: 200,
body: JSON.stringify(`Hello, ${name}! 👋`),
};
return response;
};
Click Deploy to save the code.
🧪 Step 4: Test It
1. Click “Test” > “Configure test event”
-
Event name:
TestHello
- JSON input:
{
"name": "Yash"
}
2. Click Test again — and boom 💥
You should get:
"Hello, Yash! 👋"
Congrats! 🎉 You’ve just run your first cloud function, serverless and instant.
🔄 Bonus: Trigger Lambda with API Gateway
Want to call this from a frontend app or Postman?
1. Add Trigger > API Gateway
- Choose HTTP API
- Enable Open access (for testing only — use auth in prod)
2. Click the API endpoint and try it:
curl -X POST https://your-api-id.amazonaws.com/default/helloLambda \
-d '{"name": "Dev"}' \
-H "Content-Type: application/json"
You’ve now got a working backend API — with no infrastructure. 🧙♂️
⚙️ Real-World Use Cases for Lambda
- 🧼 Image resizing after S3 upload
- 🔔 Send email notifications
- 🧾 PDF generation on-demand
- 🤖 Cron jobs for data cleanup
- 📩 Slack bot commands
- ⚡ Lightweight backend for React apps
💡 Tips for Beginners
- Use CloudWatch Logs for debugging
- Keep function under 15 minutes runtime
- Keep code simple and stateless
- Use environment variables for secrets/config
🧠 Recap
Step | What You Did |
---|---|
1️⃣ | Created a Lambda function from scratch |
2️⃣ | Wrote a greeting function in Node.js |
3️⃣ | Tested it with sample input |
4️⃣ | Optionally hooked it to an API Gateway |
That’s it — you’re now officially a serverless dev! ☁️⚡
💬 Let’s Connect!
Was that easier than you thought?
What do you want to build next with Lambda — an email bot, an image converter, or something wild?
👇 Drop your ideas in the comments, hit ❤️ if this helped you, and share this with your serverless-curious friends!
Let’s keep building — one function at a time. 🧡