Step 1 — Create a Function from Scratch
- Open the Lambda console → Create function.
- Choose Author from scratch.
- Name it (for example
hello-demo), pick a runtime (Node.js or Python), and create a new execution role with basic permissions.

AWS Lambda runs your code without you managing servers. You write a small function, upload it (or edit it in the console), and AWS runs it when something calls it.
Start with a Node.js or Python “Hello” function in the console. Connect API Gateway after the function works alone.
EC2 is a virtual computer you keep running. Lambda is “run this function when asked.” Use EC2 for always-on apps (or put them behind an ALB). Use Lambda for APIs, webhooks, and event glue.
App → API Gateway → Lambda → JSON response. Or: S3 upload / schedule / queue → Lambda.
| Word | Plain meaning |
|---|---|
Function | Your packaged code plus settings (runtime, memory, timeout) |
Handler | The entry method Lambda calls (for example index.handler) |
Runtime | Language environment (Node.js, Python, …) |
Trigger | What invokes the function (API Gateway, S3, schedule, …) |
IAM role | Permissions Lambda uses to write logs or call other AWS services |
Cold start | Extra delay when AWS prepares a fresh execution environment |
hello-demo), pick a runtime (Node.js or Python), and create a new execution role with basic permissions.Use the inline editor so the handler returns JSON text.
export const handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello from Lambda' }),
};
}; {} is fine).GET /hello) with this Lambda function.You can also register Lambda in an ALB target group. API Gateway is the simpler API learning path.
Editor changes are not live until you deploy/save.
API Gateway needs permission to call Lambda or you get 500s.
Slow cold starts or external calls need a higher timeout (within limits).
Long installs, background daemons, and local disk habits belong on EC2 or containers.
One line: create a function, test it, then put API Gateway in front for a public HTTP API.
Object storage often triggers Lambda or hosts static assets for APIs.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
9 people found this page helpful