CloudFront Functions Can Now Call APIs: cf.fetch() Pricing, Limits and vs Lambda@Edge

CloudFront Functions can now make network calls with cf.fetch(): $0.10 per million, one call per invocation, 1s timeout. Limits and Lambda@Edge compared.

Sanchana Charles19 November 202611 min read0 viewsAWS
CloudFront Functions Can Now Call APIs: cf.fetch() Pricing, Limits and vs Lambda@Edge

CloudFront Functions can now make network calls. AWS announced on 18 November 2026 that the lightweight JavaScript functions that run at CloudFront edge locations can call one of your origins mid-request with a new cf.fetch() method and act on the reply, or send fire-and-forget analytics with cf.beacon(). Network calls cost $0.10 per million, on top of the normal $0.10-per-million invocation charge. Each function gets one call per invocation, with a 1-second timeout.

Until now, any edge logic that needed live data, such as checking a token, looking up a user or asking a fraud service, meant moving to Lambda@Edge or pushing the work back to the origin. Here's what changed, the hard limits, what it costs next to Lambda@Edge, and how to use it.

What are CloudFront Functions network calls?

According to the AWS What's New post, CloudFront Functions can now "make network calls during a request and act on the responses." Two helper methods ship in the cloudfront module:

  • cf.fetch(path, options) sends a request to an origin and returns a promise that resolves to a Response (status, headers, and optionally the body as text, JSON or bytes).
  • cf.beacon(path, options) sends a request and returns immediately without waiting. It's built for analytics and audit events, and it works even when the viewer's content is served from cache.

AWS's examples include checking an AI agent's permissions and usage budget before it reaches your API or MCP server, sending request signals to a fraud-detection service, and logging analytics without adding latency.

The key design choice is that you can't call arbitrary URLs. Per the developer guide, the destination "must be an origin that is already configured on the same distribution". You pass a path and the origin's ID, not a hostname. In return, the call inherits that origin's settings:

  • Origin access control (OAC) signs the call with SigV4, so you can call a private S3 bucket or a Lambda function URL with no credentials in code.
  • VPC origins let you reach a service in a private subnet.
  • Custom origin headers and origin mTLS apply automatically.
  • Connection reuse means CloudFront often already has a warm connection.

CloudFront Functions network call limits

These quotas come from the CloudFront quotas page, and AWS says none of them are adjustable:

Limit Value
Network calls per invocation (fetch + beacon combined) 1
Timeout (send request → last byte received) 1 second
Max request body 10 KB
Max response body 10 KB
Max total headers (request or response) 10 KB
Max header name / value 256 bytes / 1,783 bytes
Max path + query string 8 KB
Function size / memory (unchanged) 10 KB / 2 MB

Other restrictions from the developer guide worth knowing before you design around this:

  • Viewer request and viewer response only. These are the only events CloudFront Functions run on anyway.
  • JavaScript runtime 2.0 required, with import cf from 'cloudfront'; on the first line.
  • Not on the free flat-rate plan. Calls throw a TypeError on free-plan distributions.
  • Not in the console Test tab or TestFunction API. Calls throw a TypeError in tests, so you must test on a deployed distribution.
  • No caching of responses. Every invocation that reaches cf.fetch() makes a real call.
  • AWS WAF doesn't inspect these calls. Your web ACL sees viewer requests, not the function's outbound requests.
  • Not supported with continuous deployment (staging distributions) or in Connection Functions.
  • Uncaught errors return HTTP 503 to the viewer. Wrap every call in try/catch and decide whether to fail open or fail closed.

How much do CloudFront Functions network calls cost?

From the CloudFront pay-as-you-go pricing page:

Item Price
CloudFront Functions invocations $0.10 per 1M (2M/month always free)
Network calls $0.10 per 1M, in addition to invocations (no free allowance listed)
KeyValueStore reads from functions $0.03 per 1M (2M/month always free)
Lambda@Edge requests $0.60 per 1M (no free tier)
Lambda@Edge duration $0.00005001 per GB-second

On CloudFront flat-rate plans, network calls are included at no extra cost on Pro ($15/month) and above. The other tiers are Business at $200/month and Premium at $1,000/month, per the CloudFront pricing page. The Free plan doesn't support them.

Illustrative cost: 100 million requests a month

This is our own estimate using list prices above. It ignores data transfer and request fees, which you pay either way.

Approach Calculation Approx. monthly cost
CloudFront Function + cf.fetch() on every request (100M − 2M free) × $0.10/M + 100M × $0.10/M ≈ $19.80
Lambda@Edge viewer-request function (128 MB, assumed 50 ms average) 100M × $0.60/M + 0.125 GB × 0.05 s × 100M × $0.00005001 ≈ $91.26

Your origin (the auth service, Lambda URL or API that the function calls) still costs whatever it costs. And remember the function's call isn't cached. If you can replace a lookup with a KeyValueStore read at $0.03 per million, that is cheaper again.

CloudFront Functions vs Lambda@Edge: which should you use now?

"CloudFront Functions vs Lambda@Edge" is one of the most-searched CloudFront questions, and this launch changes the answer for a big group of use cases. Here's our decision table:

If you need… Use
One quick lookup per request (token check, A/B bucket, bot score) that returns < 10 KB within 1 s CloudFront Functions + cf.fetch()
Fire-and-forget analytics on every request, including cache hits CloudFront Functions + cf.beacon()
Static or slow-changing data (redirect maps, feature flags) CloudFront Functions + KeyValueStore (no network call)
More than one external call per request Lambda@Edge
npm packages, larger code, or bodies over 10 KB Lambda@Edge
Logic on origin request / origin response events Lambda@Edge
Calling an arbitrary third-party URL not set up as an origin Lambda@Edge (or add it as an origin first)
Work that can take longer than 1 s (the quotas page lists a 30-second Lambda@Edge function timeout) Lambda@Edge

AWS's own guidance in the docs: use a network call when "the data changes between requests and you need a current answer", or when the dataset is too large for a key value store (max 5 MB). Use KeyValueStore when data is static, or when you need more than one lookup, since a function can read KVS many times but call the network only once. You can combine both.

How to use cf.fetch() in a CloudFront Function

  1. Add the service you want to call as an origin on the distribution, for example your auth API, an S3 bucket with OAC, or a Lambda function URL. Note its Name (the origin ID).
  2. Make sure the distribution isn't on the Free flat-rate plan and isn't using continuous deployment.
  3. Create a CloudFront Function on runtime cloudfront-js-2.0.
  4. Write an async handler that imports cf and wraps the call in try/catch.
  5. Publish and associate it with the viewer-request (or viewer-response) event of the cache behaviour.
  6. Test on the deployed distribution, not the Test tab. Read the call's own x-amz-cf-id from response.headers when debugging.

Here is AWS's own example from the developer guide. It reads a configuration object from an S3 origin and fails open if the lookup fails:

import cf from 'cloudfront';

async function handler(event) {
    const request = event.request;

    try {
        const response = await cf.fetch('/config/experiments.json', {
            originId: 'config-bucket',
            includeBody: true,
        });

        if (response.ok) {
            const config = await response.json();
            request.headers['x-experiment'] = { value: config.activeExperiment };
        }
    } catch (e) {
        console.log('Config lookup failed: ' + e.name);
    }

    return request;
}

Gotchas the docs call out:

  • includeBody defaults to false. Without it, json() resolves to null. That will be the number-one "why is my response empty?" bug.
  • Methods must be upper case. 'post' throws a TypeError.
  • Headers use a plain object ({ 'content-type': 'application/json' }), not the { value: … } shape from event.request.headers.
  • The body can be read only once.
  • Viewer headers aren't copied over (except X-Forwarded-For, Via and CDN-Loop). Pass anything the origin needs explicitly.
  • Lambda function URL + POST/PUT with a body needs you to add an x-amz-content-sha256 header yourself.
  • Promise.all() with two fetches throws. It's one call, full stop.

What are developers saying?

The launch is a day old, and we didn't find any Hacker News or Reddit discussion of it yet. The early reaction is showing up in code:

  • AWS's amazon-cloudfront-functions samples repo merged a pull request on 18 November adding 12 network-call patterns. They include an AI-agent authoriser, Cognito token validation, sticky A/B variants, a waiting room, origin health failover, and "markdown on demand" for AI agents. The PR notes that because test-function rejects network calls, "the READMEs describe testing on a deployed distribution."
  • On the aws-jwt-verify project, a proposal issue suggests a CloudFront Functions variant that fetches the JWKS on a cache miss and stores it in KeyValueStore. It points out the main catch: "CloudFront Functions cannot import npm packages and are limited to 10 KB, so the library itself cannot run there."

Questions developers are searching for include CloudFront Functions limitations, CloudFront Functions pricing, CloudFront Functions vs Lambda@Edge and CloudFront Functions examples. We answer those in the tables above and the FAQ below.

Editor's take

This removes the most common reason teams reached for Lambda@Edge. Authorisation checks, per-request feature assignment and edge analytics can now live in a function that's roughly a fifth of the price in our estimate, with no separate region to deploy to. The limits are strict, though: one call, one second, 10 KB each way, and no response caching. That makes this a tool for small, fast lookups against your own services. It doesn't replace general-purpose edge compute. The AI-agent angle is the interesting one. Together with AWS WAF's AI-traffic monetisation and Cognito token exchange for agents, AWS is clearly building an edge-side toolkit for metering and authorising bots. Expect more of it at re:Invent 2026. If you're comparing auth options closer to the API, see our guide to API Gateway JWT authorizers vs Lambda authorizers.

FAQ

Can CloudFront Functions make network calls?

Yes, since 18 November 2026. Use cf.fetch() or cf.beacon() from the cloudfront module on JavaScript runtime 2.0, limited to one call per invocation to an origin on the same distribution.

What is the CloudFront Functions timeout for network calls?

1 second, measured from sending the request to receiving the last byte. It ignores any longer response timeout set on the origin and can't be raised.

How much do CloudFront Functions cost?

$0.10 per million invocations (first 2 million per month free), plus $0.10 per million network calls if you use them. On flat-rate plans, network calls are included from the Pro plan ($15/month) up.

What are the CloudFront Functions limitations?

10 KB code size, 2 MB memory, viewer events only, no npm packages, and now one network call per invocation with 10 KB request/response bodies and a 1-second timeout.

CloudFront Functions vs Lambda@Edge: which is cheaper?

CloudFront Functions. Requests are $0.10/M vs $0.60/M for Lambda@Edge, plus Lambda@Edge charges for duration. In our 100M-request estimate, about $20 vs about $91 a month.

Can cf.fetch() call any URL?

No. It can only call an origin already configured on the same distribution, by origin ID and path. To call a third-party API, add it as a custom origin first.

Why does cf.fetch() fail in the CloudFront console test?

Network calls aren't supported in the Test tab or the TestFunction API and throw a TypeError. Wrap calls in try/catch and test on a deployed distribution.

Does cf.fetch() work on the CloudFront free plan?

No. Distributions on the free flat-rate plan don't support network calls.

Sources

Featured image: An Amazon data center technician working between racks of networking equipment. Official Amazon press photo of an AWS data center, not a CloudFront edge location. Source

Share:

Comments

Leave a comment