Lambda Architecture
This cost-optimized serverless architecture is suitable for most image transformation workloads with images up to 6 MB.
Important
This solution is intended for customers with public applications who want to provide an option to dynamically change or manipulate their public images. Because of these public requirements, this template creates a publicly accessible, unauthenticated CloudFront distribution and Amazon API Gateway
Lambda architecture for cost-optimized image processing
Note
AWS CloudFormation resources are created from AWS Cloud Development Kit
The high-level process flow for the Lambda architecture is as follows:
-
An Amazon CloudFront
distribution provides a caching layer to reduce the cost of image processing and the latency of subsequent image delivery. -
Amazon API Gateway
provides endpoint resources and initiates the AWS Lambda function. -
A Lambda function retrieves the image from a customer’s existing Amazon S3
bucket and uses sharpto return a modified version of the image to the API Gateway. -
A solution-created S3 bucket provides log storage, separate from your customer-created S3 bucket for storing images.
-
(Optional) If you enter
Yesfor the Enable Signature template parameter, the Lambda function retrieves the secret value from your existing AWS Secrets Managersecret to validate the signature. -
(Optional) If you use the smart crop or content moderation features, the Lambda function calls Amazon Rekognition
to analyze your image and returns the results. -
The viewer request is proxied through an Amazon CloudFront function to normalize headers and query parameters for improved cache hit rates.