API Gateway and function URLs

Intermediate · 17 min

Putting HTTP in front of Lambda: function URLs, HTTP and REST APIs, authorization, throttling, timeouts, payload limits and choosing.

Before thisPolicy documents and evaluation logicLambda functions and the execution modelLambda concurrency, cold starts and failures

AWS Events · 21 min · from 3:52

API Gateway and function URLs

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by AWS EventsReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • A function URL is a free, direct HTTPS endpoint for one function, with IAM authentication or none.
  • HTTP APIs are the simpler, cheaper API Gateway type. REST APIs add API keys and usage plans, WAF, caching, request validation and private endpoints.
  • API Gateway also has WebSocket APIs, and can call AWS services directly without a function.
  • Every layer has a timeout and payload limit. REST integrations default to 29 seconds and HTTP APIs stop at 30, however long the function may run.
  • Throttling defaults are shared across an account and Region. Set per-route or per-stage limits to protect what is behind.
  • An authorizer checks who is calling. Your code still has to check what that caller may touch.

A function has no address

A Lambda function is invoked through the AWS API, with a signed request. Browsers, mobile apps and webhooks speak plain HTTP. Something has to stand in front, turn a request into an event and turn your return value into a response.

Function URLs

The smallest answer is a function URL, an HTTPS endpoint like https://<id>.lambda-url.eu-west-1.on.aws attached to one function or alias. There’s no extra charge beyond Lambda. It has two auth types:

  • AWS_IAM: callers sign requests and need lambda:InvokeFunctionUrl and lambda:InvokeFunction.
  • NONE: no authentication. A resource policy must allow public access, and your code is the only gate.

It suits webhooks, internal tools and service-to-service calls. It has no routing, no request throttling by client and no custom domain of its own. Put CloudFront in front if you need a domain or WAF.

API Gateway

Amazon API Gateway is a managed front door, with routing, authorization, throttling and custom domains. Think of a reception desk that checks visitors and directs them, so the staff behind don’t each need a lock.

HTTP API REST API
Price and complexity lower higher
IAM, JWT and Lambda authorizers yes yes
API keys and usage plans no yes
AWS WAF, caching, request validation no yes
Private endpoints no yes
Response streaming no yes

Start with an HTTP API and move to REST when you need something in its column. The names are unhelpful: both serve HTTP, and either can be a REST-style API. A third type, WebSocket, keeps connections open and routes messages to functions.

The event and the response

With a proxy integration, the request arrives as an event and you return status, headers and body:

def handler(event, context):
    order = ORDERS.get(event["pathParameters"]["id"])
    if order is None:
        return {"statusCode": 404, "body": json.dumps({"error": "not found"})}
    return {"statusCode": 200,
            "headers": {"content-type": "application/json"},
            "body": json.dumps(order)}

Called locally with hand-written events for orders 42 and 7, it returned 200 and 404. An HTTP API route such as GET /orders/{id} fills pathParameters. Event shapes differ between payload format versions, so write tests against the one you configured. Integrations can also call AWS services such as SQS or DynamoDB directly, skipping a function that only forwards.

Limits that shape design

Limit Value
HTTP API integration timeout 30 seconds
REST integration timeout 29 seconds, raisable for Regional and private APIs
API Gateway payload 10 MB
Lambda synchronous payload 6 MB
Default account rate 10,000 requests per second per Region

A function allowed to run for 30 minutes still answers to the shortest timeout in the chain. Long work should return 202 and continue through a queue or workflow. Large uploads should go straight to S3.

Throttling uses a token bucket: a steady rate plus a burst, and excess requests get 429. Set stage or route limits so one endpoint can’t starve the rest. Also remember Lambda concurrency is a second limit behind this one.

Authorization

Use JWT authorizers for tokens from your identity provider, IAM for AWS callers, and Lambda authorizers for custom logic. An authorizer answers “is this a valid caller?”. Whether that caller may read order 42 is still your code’s job. CORS controls which browser origins may call; it isn’t access control.

Turn on access logs and watch latency, 4xx and 5xx counts separately.

AWS added another option in 2026, Lambda Web Functions, which run an ordinary Node.js or Python web server behind its own endpoint. It’s new and has a different execution model, so check its documentation before choosing it.

About the video

The embed is a clip from AWS’s re:Invent 2023 talk “I didn’t know Amazon API Gateway did that” (SVS323), 3:52 to 24:35. Its chapters there cover API fundamentals, API types and traffic management, and integration patterns. It predates response streaming on REST APIs and doesn’t cover function URLs, which the linked video from Ajay Wadhara does. I judged it from chapters and description; there’s no audio-language flag, though title and captions are English.

What was run: the handler ran in local Python with made-up events. A function URL and HTTP API route were created on moto 5.1.22, which can’t execute or serve them without Docker. Limits and features come from AWS docs, checked in November 2026.

Check yourself

  1. 01You need per-customer quotas with API keys. Which option?

    A REST API with usage plans. HTTP APIs and function URLs don't offer them. API keys identify clients for quotas and shouldn't be your only authentication.

  2. 02A report takes two minutes to generate and the HTTP API returns an error at about 30 seconds. What design change helps?

    Make it asynchronous. Accept the request, start a job through a queue or workflow, return 202 with a status URL, and let the client poll or be notified.

  3. 03What does setting a function URL's auth type to NONE require you to do in code?

    Authenticate and authorize every request yourself, since Lambda does neither. Anyone with the URL can invoke the function and spend your concurrency.

  4. 04One noisy route is causing 429s across unrelated APIs in the account. Why can that happen?

    API Gateway's request rate quota is per account per Region. Without route, stage or client limits, one API can consume it all.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark