Support Documents
No data found.

Understanding [email protected]

Lab Details

  1. This lab walks you through to create an Amazon S3 bucket with two HTML pages (User and Admin login page) and use this bucket as the origin of your CloudFront distribution. Now integrate a Lambda function at Request Origin of CloudFront to automatically redirect to the appropriate HTML page.

  2. You will practice the lab using Cloudfront distribution, Lambda function and S3 bucket.

  3. Duration: 1 hour 15 minutes

  4. AWS Region: US East (N. Virginia) us-east-1


What is [email protected]?

  • [email protected] is a feature of Amazon CloudFront that lets you run code closer to users of your application, which improves performance and reduces latency.

  • You don't have to provision or manage infrastructure in multiple locations around the world.

  • You only have to pay for the Lambda function time and no other extra changes.

  • [email protected] runs your code in response to events generated by the Amazon CloudFront content delivery network (CDN). Just upload the code to AWS Lambda, run and scale your code with HA at an AWS location closest to your end user.

  • There are no servers to manage and you can customize your content delivery.

  • You can add your lambda code at four different events, they are :

    • Viewer Request: Pass the viewer request to lambda function, process it and then pass it to the distribution.

    • Origin Request: Pass the request that comes from the distribution to lambda function, process it and then pass it to origin.

    • Origin Response: Pass the response that comes from the Origin to lambda function to process.

    • Viewer Response: Pass the response from the distribution to the lambda function to process it and then send it to the user.

What is CloudFront?

  • Amazon CloudFront is a content delivery network (CDN) offered by AWS.

  • CDN provides globally-distributed network of proxy servers which cache content, i.e., web videos or other bulky media, more locally to consumers, thus improving access speed for downloading the content.

  • CloudFront service works on a pay-as-you-go basis.

  • CloudFront works with origin servers like S3, EC2 where the content is stored and is pushed out to multiple CloudFront servers as content is requested.

  • When CloudFront is enabled, the content is stored on the main S3 server.

  • Copies of this content are created on a network of servers around the world called CDN.

  • Each server within this network is called an Edge server, which will only have a copy of your content.

  • When a request is made to the content, the user is provided from the nearest edge server.

  • CloudFront has features similar to dynamic site acceleration, a method used to improve online content delivery.

  • CloudFront accelerates the delivery of dynamic content by moving it closer to the user to minimize internet hops involved in retrieving the content.

  • CloudFront's Web distribution supports "Progressive" download i.e., data from S3 is cached and then streamed without disruptions.

  • Due to that, the user cannot move front or back in the video i.e., the video is processed bit by bit.

  • CloudFront's Web distribution support "Streaming" allows users to directly watch without any download.

  • Due to that, the user can move front or back in the video, the latency is based on the size of the file and the customer Internet bandwidth.

  • This service is beneficial for those developing a website that distributes a lot of content and needs to scale-up.

  • It helps reduce costs and improve the performance of a website by providing high data transfer speeds and low latency.

Architecture Diagram


Case Study

  • In this lab, we are implementing [email protected] at origin request. The lambda will be redirecting the path to the appropriate HTML page based on the users URL.

  • The cloudfront request that goes to the S3 bucket will be redirected to the lambda and once the lambda is executed then only the request goes into the S3 bucket placed at the Origin.

Case Study Diagram


Task Details

  1. Log into AWS Management Console.

  2. Create a S3 Bucket.

  3. Upload objects and make them public.

  4. Create a Lambda function.

  5. Create a Lambda version.

  6. Create an Amazon CloudFront distribution.

  7. Test the distribution.

  8. Validation of the lab.

  9. Deleting AWS resources