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.
Why it matters
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.
Integrate a route (for example GET /hello) with this Lambda function.
Allow API Gateway to invoke Lambda when the console prompts for permission.
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.
Avoid these
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.
Remember
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.