38

What is the difference between simple aws lambda and aws lambda@edge ?

mnhmilu
  • 2,327
  • 1
  • 30
  • 50

4 Answers4

31

Lambda executes functions based on certain triggers. The use case for Lambda is quite broad and there is heavy integration with many AWS Services. You can even use it to simply execute the code via AWS's API and receive the code into your scripts separate from AWS. Common use cases include Lambdas being simply executed and the output received, plugged into API Gateway to serve user requests, modifying objects as they are placed into S3 buckets, etc.

Lambda@Edge is a service that allows you to execute Lambda functions that modify the behaviour of CloudFront specifically. Lambda@Edge simply runs during the request cycle and makes logical decisions that affect the delivery of the CloudFront content.

https://aws.amazon.com/lambda/features/

https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html

HammoTime
  • 493
  • 5
  • 7
4
  • has to be created in us-east-1 region
  • if code taken from bucket, bucket also needs to be in us-east-1 region
  • you can't pass environment variables the same way as to normal lambda fn. Either you need to hardcode values during build process or hardcode env and fetch values from somewhere else.
Kamil Biela
  • 706
  • 1
  • 6
  • 13
  • There is no region for S3 – NG. Feb 18 '20 at 12:15
  • 1
    And although the lambda appears in us-east-1, it's actually replicated to all CloudFront edge locations (hence @edge). – medv May 14 '20 at 04:22
  • 1
    @NG there is region for s3 bucket, you even have that info on bucket list. Bucket name is global, but still you create bucket in a region. – Kamil Biela Jul 15 '20 at 16:46
3
  • Lambda@Edge is Lambda functions in response to CloudFront events.
  • You still create lambda@edge function under Lambda, but Lambda@Edge function must be created in us-east-1.
  • You need configure lambda@edge to the cloundfront distribution behavior on viewer request or others.
Jacob
  • 1,776
  • 14
  • 11
2

Lambda is a serverless AWS compute service that allows user to run code as function trigger. In file processing, optimization, lot of use cases.

On the other hand Lamda@Edge is extension of AWS lambda, is a feature of cloudfront that allows user run code closer to the application, so improves performance and reduce latency.

Here is the official documentation describe nicely about Lambda@Edge https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html