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

Quick anatomy: what you need

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)

  1. 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)
  2. Paste the handler code (index.js) into the inline editor and click Deploy.
  3. 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)

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:

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