AWS Lambda for Beginners

Beginner
10 min read
Updated: Nov 2026
4 steps
No servers to patch

What Is AWS Lambda?

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.

  • No EC2 to patch for simple handlers.
  • Pay when it runs (requests + compute time).
  • Common door: API Gateway → Lambda.
Beginner tip.

Start with a Node.js or Python “Hello” function in the console. Connect API Gateway after the function works alone.

In Simple Words

Lambda vs EC2

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.

A tiny traffic picture

App → API Gateway → Lambda → JSON response. Or: S3 upload / schedule / queue → Lambda.

Official docs.

What is AWS Lambda?

Words You Will See

WordPlain meaning
FunctionYour packaged code plus settings (runtime, memory, timeout)
HandlerThe entry method Lambda calls (for example index.handler)
RuntimeLanguage environment (Node.js, Python, …)
TriggerWhat invokes the function (API Gateway, S3, schedule, …)
IAM rolePermissions Lambda uses to write logs or call other AWS services
Cold startExtra delay when AWS prepares a fresh execution environment

What You Need First

  • An AWS account with permission to create Lambda functions.
  • Optional: readiness to follow API Gateway next for a public HTTP URL.

Step-by-Step

Step 1 — Create a Function from Scratch

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

Step 2 — Return a Simple Message

Use the inline editor so the handler returns JSON text.

index.mjs (Node.js idea)
export const handler = async (event) => {
  return {
    statusCode: 200,
    body: JSON.stringify({ message: 'Hello from Lambda' }),
  };
};

How It Works

  1. Deploy / Save so the latest code is what Lambda runs.
  2. statusCode + body are common when API Gateway will call this function later.

Step 3 — Create a Test Event

  1. Choose Test, create a hello event (empty JSON {} is fine).
  2. Run the test and confirm the response shows your message.
  3. Open CloudWatch logs from the monitor tab if something fails.

Step 4 — Put API Gateway in Front

  1. Follow Amazon API Gateway to create an HTTP API.
  2. Integrate a route (for example GET /hello) with this Lambda function.
  3. Allow API Gateway to invoke Lambda when the console prompts for permission.
  4. Call the invoke URL in a browser or with curl.
ALB alternative.

You can also register Lambda in an ALB target group. API Gateway is the simpler API learning path.

Common Beginner Mistakes

Forgetting to deploy code

Editor changes are not live until you deploy/save.

No invoke permission

API Gateway needs permission to call Lambda or you get 500s.

Timeout too short

Slow cold starts or external calls need a higher timeout (within limits).

Using Lambda like a full VM

Long installs, background daemons, and local disk habits belong on EC2 or containers.

Key Takeaways

One line: create a function, test it, then put API Gateway in front for a public HTTP API.

Frequently Asked Questions

AWS Lambda runs your code in response to events without you managing servers; you upload a function, choose a runtime, and AWS scales the compute when the function is invoked.
Not for simple APIs or event handlers. Use EC2 (or containers) when you need long-running processes, custom OS packages, or always-on servers. Many apps mix both.
API Gateway is a common front door: clients call an HTTP URL, API Gateway invokes your Lambda function, and returns the function’s response. See the API Gateway beginner guide.
Classic event functions are limited per invocation (commonly up to 15 minutes). Design short tasks; use other services for long batch jobs.
You typically pay per request and compute time (GB-seconds), with a free tier for many accounts. Check current AWS Lambda pricing before production use.
Yes. An ALB can forward to a Lambda target group. Beginners often start with API Gateway + Lambda for APIs instead.

Next: Amazon S3

Object storage often triggers Lambda or hosts static assets for APIs.

S3 tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful