on
Serverless 101: Deploying Your First AWS Lambda Function
Serverless can feel like magic: you write a tiny piece of code, hand it to the cloud, and it runs when something happens—no servers to babysit, no operating-system updates to schedule. In practice, it’s more like hiring a session musician for one song: you pay only for the time they play and don’t worry about their tour bus. AWS Lambda is one of the most popular serverless platforms and is a great place to start learning the model. The official AWS guides walk through the basic flow: create a function, give it permissions, invoke it, and check the logs. (docs.aws.amazon.com)
What you’ll build
- A tiny Node.js “Hello” function that returns JSON.
- A public HTTPS endpoint using a Lambda Function URL so you can curl it from your laptop (no API Gateway needed). This keeps the tutorial focused and practical for absolute beginners. The Lambda console has a friendly “create function” flow that guides you through the basics. (docs.aws.amazon.com)
Quick anatomy: what you need
- An AWS account and an IAM role that allows Lambda to write logs (the console can create this for you automatically).
- A small handler file (Node.js shown here).
- The Lambda console or AWS CLI to create and publish the function. The AWS tutorials and getting-started guides show these steps in detail. (docs.aws.amazon.com)
The code (Node.js — hello world) Paste this into the inline editor in the Lambda console or save as index.js and zip it for CLI deployment.
// index.js
exports.handler = async (event) => {
const name = (event.queryStringParameters && event.queryStringParameters.name) || 'world';
const body = { message: `Hello, ${name}!` };
return {
statusCode: 200,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
};
};
Step-by-step (console)
- Open the Lambda console and choose Create function → Author from scratch. Name it helloLambda, choose Node.js (current LTS or runtime you prefer), and let the console create a basic execution role that can write CloudWatch Logs. The AWS getting-started pages walk this dialog through with screenshots. (docs.aws.amazon.com)
- Paste the handler code (index.js) into the inline editor and click Deploy.
- Test in-console: create a simple test event and invoke the function—Lambda shows the returned payload and execution details. The console also links the CloudWatch log group where invocation logs are stored. (docs.aws.amazon.com)
Expose it to the web (Lambda Function URLs) If you want a quick HTTP endpoint without deploying API Gateway, Lambda Function URLs provide a built-in HTTPS invoke endpoint you can create from the function’s Configuration → Function URL section. After creating a function URL, you can curl it or open it in a browser and pass query parameters (like ?name=Riley). This is ideal for simple demos and learning because it reduces surface area while you focus on the function itself. (docs.aws.amazon.com)
Example curl test (after creating a function URL)
curl 'https://<your-function-id>.lambda-url.us-east-1.on.aws?name=Riley'
# -> {"message":"Hello, Riley!"}
CLI alternative (optional) If you prefer the AWS CLI, you can zip your code and run aws lambda create-function with –runtime, –handler, –role, and the zipped file. The AWS docs show the exact parameters and IAM requirements. The console remains the simplest route for a first-time experience. (docs.aws.amazon.com)
What to watch for (practical tips)
- Timeouts and memory: Lambda charges are tied to configured memory and execution time. Set timeouts slightly above the expected runtime; long-running tasks may be better on other platforms.
- Cold starts: when a function hasn’t run recently, the first invocation may take longer while the runtime initializes. For learning and small workloads this is fine; for latency-sensitive apps, explore provisioned concurrency or other optimizations.
- Logs: CloudWatch is where your function output goes. Use clear logging during development, then reduce verbosity in production. The AWS docs explain the log-group behavior created for each function. (docs.aws.amazon.com)
A recent development worth knowing AWS keeps evolving how Lambda can serve web traffic. One newer option is AWS Lambda Web Functions, announced as a way to run web-centric functions behind a global URL with lower-latency routing and Node.js 24 support at launch. For someone learning serverless, it’s useful to know Function URLs are not the only game in town—Web Functions are targeted at web workloads and make different trade-offs (for example, global routing behavior). If you’re experimenting with simple web endpoints today, Function URLs are the lowest-friction path; watch Web Functions as AWS documents language and feature support more broadly. (aws.amazon.com.cdn.amazon.com)
Keep the first deployment simple Treat your first Lambda as an experiment. The fastest route to learning is a tight loop:
- edit code → deploy (console or CLI) → invoke → check logs → repeat. That rhythm mirrors how musicians rehearse a riff: small changes, immediate feedback, progressive refinement. AWS’s step-by-step tutorials and hands-on labs provide the screenshots and explicit commands if you want more structure. (aws.amazon.com)
Closing notes Your first Lambda function is less about building a production service and more about understanding the serverless lifecycle: code, permissions, triggers, and observability. Once that loop feels comfortable, you can explore connecting the function to S3 events, DynamoDB streams, or an API Gateway-backed API, and then choose the deployment pattern—console, CI/CD pipelines, Serverless Framework, SAM, or CDK—that fits your team. For now, enjoy the moment: you’ve taken your first step into a model that offloads infrastructure so you can focus on the part that matters—writing the logic that actually does the work. (docs.aws.amazon.com)
References
- AWS Lambda developer guide and getting-started tutorials. (docs.aws.amazon.com)
- Creating and managing Lambda Function URLs. (docs.aws.amazon.com)
- Announcing AWS Lambda Web Functions (new web-centric offering). (aws.amazon.com.cdn.amazon.com)
- AWS Lambda resources and workshops for hands-on practice. (aws.amazon.com)