Posted On: Nov 21, 2017

Starting today, you can use three new capabilities with Lambda@Edge that can further help you build personalized content for your viewers while improving latency and simplifying your origin infrastructure. First, with content-based dynamic origin selection, you can route requests to different backend origin servers based on request attributes such as viewer location, viewer device type, HTTP headers, URL path, query string or cookies. Second, you can make remote network calls from Amazon CloudFront viewer-facing events. Third, you can generate binary data from your Lambda@Edge functions which lets you deliver richer, more customized content using Amazon CloudFront. We have also increased the limits for Lambda@Edge functions. You can choose up to 1536MB of memory, deploy larger packages up to 50MB, and implement Lambda@Edge functions with longer timeouts – up to 30 seconds.  

Content-based dynamic origin selection: Previously with Lambda@Edge, you could only forward requests to a pre-defined origin that you configured for your CloudFront distribution. Now you can front multiple backend origin application services with Amazon CloudFront and use Lambda@Edge to route requests to the appropriate origin dynamically, based on the attributes of the request. For example, you could have multiple microservices based backend origins that your Lambda@Edge functions can dynamically route to by inspecting request attributes like query strings, headers or cookies. Or you can route your viewers to the most optimal origin for latency or data locality if you happen to run geographically distributed applications in different AWS regions. Content-based dynamic origin selection also lets you simplify your origin infrastructure by moving request routing logic from a fleet of reverse proxy servers that you would have had to manage to serverless Lambda@Edge functions.

Network calls on viewer-facing events: In addition to the remote network calls from origin-facing CloudFront events, Lambda@Edge now supports remote network calls from viewer-facing CloudFront events. For instance, you can now make remote calls to your authentication servers to verify user-privilege levels and serve premium vs. non-premium content based on what each user is authorized for.

Advanced response generation: Now with support for binary responses (such as images) and higher Lambda function limits, you can move more complex logic to the edge than was possible previously. For example, with remote calls and binary response generation, you can now call services like Amazon Rekognition to find interesting portions of images and resize, crop or compress them, add image watermarking or manipulate the images for optimal viewing experience on various viewer devices. As a content publisher, you can dynamically assemble content for each viewer from multiple external sources, run compute-intensive logic, and generate customized responses. Lambda@Edge makes all of this possible at low latencies for your viewers, and without the need to provision or manage your own servers.

There are no additional charges for using these new features. To learn more about Lambda@Edge, visit the product page. For more information on how to use these capabilities, please see the resources below:  

  • See a code sample that demonstrates content-based dynamic origin selection. 
  • Learn how to use dynamic origin selection in this blog post.
  • To learn more about generating HTTP response, see Generating HTTP Response in the CloudFront Developer Guide.
  • For more details on Lambda@Edge deployment limits, see our limits page.