EdgeServices

Posted by Paul Taylor on November 28, 2019 · 2 mins read

A Pair of Lambda@Edge Functions for Executing Common Operations on Request

I’ve talked in several previous posts about the way we are beginning to architect digital experinces, to support an elastically-scalable approach. We call this approach “serverless”. I’ve also talked about using Amazon Web Services to provide the underlying infrastructure to support the serverless deployment model.

Several previous posts have introduced AWS Lambda Functions aimed at turning a serverless infrastructure into a fully-functional web server environment, adding the missing capability to Amazon S3 and Amazon CloudFront (EdgeAuthorize, EdgeAngular). Now, we’ve spent time merging the capabilities of these services and extending to provide a highly-configurable set of enhancements for cloud-based computing within Amazon Web Services.

EdgeServices

Designed to replace functionality traditionally managed within web.config, web.xml or .htaccess files with a single JSON file, located within the root of an Amazon S3 Bucket (the origin). EdgeServices consists of a pair of AWS Lambda Functions, written in Node.js, which can be deployed to Lambda@Edge to support edge-node execution, ensuring high performance globally. The Lambda@Edge Functions are designed to execute upon both “Origin Request” and “Origin Response” Amazon CloudFront Behaviors, allowing the result to be cached for future requests, adding to the edge-based execution performance benefits.

Harness EdgeServices to:

  • Set a Default Document;
  • Restrict access to an entire site or path, using HTTP 401 Authentication;
  • Deny access to an entire site or path;
  • Perform HTTP 301 and 302 redirects;
  • Perform complex rewriting functions (similar to mod_rewrite);
  • Handle custom error pages and behaviours;
  • Manage HTTP Headers.

EdgeServices Sequence Diagram EdgeServices Sequence Diagram

Configuration instructions are in the EdgeServices GitHub public repository, along with the source code, which is available under the MIT License. See https://github.com/ptylr/Lambda-at-Edge/tree/master/EdgeServices/.