Serverless 101: Expose Your First AWS Lambda with a Function URL

Serverless lets you run code without managing servers — and one of the quickest ways to expose a tiny HTTP endpoint is with an AWS Lambda function URL. Function URLs give a dedicated HTTPS endpoint for a single Lambda, removing the need to configure API Gateway for simple use cases such as webhooks, form validators, or quick proof-of-concept APIs. This guide walks through the concept, the minimal steps to deploy and call your first function URL, and important security and cost considerations to keep in mind. (docs.aws.amazon.com)

Why use a function URL?

Note: function URLs are public HTTP(S) endpoints. If you need private-only access or richer API features (rate limits, authorizers, built-in WAF integration), consider API Gateway or place CloudFront in front of the URL. (docs.aws.amazon.com)

Prerequisites

The AWS tutorial for building a webhook with function URLs is a handy step-by-step reference; much of this article borrows the same practical approach. (docs.aws.amazon.com)

Quick example: create a tiny Node.js function and add a function URL

1) Create a minimal handler (index.mjs)

// index.mjs
export const handler = async (event) => {
  return {
    statusCode: 200,
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({ message: 'Hello from Lambda function URL!', eventSummary: { method: event.requestContext?.http?.method || 'N/A' } })
  };
};

2) Zip and create the Lambda using AWS CLI (example; adjust function-name and role ARN)

zip function.zip index.mjs
aws lambda create-function \
  --function-name my-first-furl \
  --runtime nodejs24.x \
  --handler index.handler \
  --zip-file fileb://function.zip \
  --role arn:aws:iam::123456789012:role/lambda-exec-role

3) Add a function URL (public, no signing)

aws lambda create-function-url-config \
  --function-name my-first-furl \
  --auth-type NONE \
  --cors-config AllowOrigins="*"

The CLI call above creates an HTTPS endpoint (form: https://.lambda-url..on.aws) you can call immediately. For more configuration options (aliases, CORS, or IAM auth), see the Lambda function URL docs. ([docs.aws.amazon.com](https://docs.aws.amazon.com/lambda/latest/dg/urls-configuration.html?utm_source=openai))

Calling the function URL

curl -i https://<your-id>.lambda-url.us-east-1.on.aws

Example (IAM auth) using curl with SigV4 (replace region and URL):

curl --aws-sigv4 "aws:amz:us-east-1:lambda" --user "AKIA...:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" https://<your-id>.lambda-url.us-east-1.on.aws

If you prefer, put the signing step behind CloudFront (see below) or use SDK clients that handle signing for you. (docs.aws.amazon.com)

CORS, resource policies and basic hardening

If you need to accelerate delivery and reduce the attack surface, put CloudFront in front of your function URL and enable Origin Access Control (OAC) for the Lambda origin. OAC configures CloudFront to sign origin requests with SigV4 so direct calls to the function URL can be blocked while CloudFront remains the only allowed client. This lets you use WAF, Shield, custom domains, and caching while keeping the function URL from being openly callable. (aws.amazon.com)

Cost and cold-start visibility: an important recent change

AWS standardized billing for the Lambda initialization (INIT) phase effective August 1, 2025. That means some time spent loading packages, native dependencies, or heavy initialization can now appear in billing. For small functions this won’t move the needle much, but for languages or packaging approaches that do heavy initialization you should measure INIT duration (CloudWatch metrics and logs) and optimize: smaller bundles, precompiled artifacts, or provisioned concurrency where appropriate. Track init times and factor them into your cost estimate as you experiment. (aws.amazon.com)

Practical tips for a smooth first deployment

When not to use a function URL

Summary

Lambda function URLs are a pragmatic, low-friction path to expose a single serverless endpoint in minutes. They’re ideal for webhooks, tiny APIs, and quick prototypes. But remember: secure appropriately (NONE vs. AWS_IAM versus CloudFront OAC), watch initialization times now that INIT billing has been standardized, and pick API Gateway when you need a richer API feature set. The Lambda function URL docs and the webhook tutorial provide concise, step-by-step references for each command and configuration option. (docs.aws.amazon.com)

Happy building — keep the handler small, test the endpoint, and monitor init times as you iterate.