Amazon CloudFront to Amazon S3 with AWS Lambda@Edge

Amazon CloudFront → Lambda@Edge (Auth) → Amazon S3

Create a CloudFront Distribution to upload files to an S3 bucket. Uses Lambda@Edge for authentication.

This pattern creates an Amazon CloudFront distribution that can be used to upload files to an Amazon S3 bucket.
It uses a Lambda@Edge function to verify a JSON Web Token (JWT) issued by Amazon Cognito.
This allows authorized uploads of large objects to S3 via CloudFront without providing public access to the S3 bucket.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/cloudfront-lambda-edge-s3-cdk

Deploy

cdk deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: cdk destroy.

Created by:

Thomas Moore

Thomas Moore

Senior Solutions Architect @ Amazon Web Services

Follow on LinkedIn

Josh Hart

Senior Solutions Architect @ Amazon Web Services

Follow on LinkedIn