Questions tagged [aws-lambda-edge]

AWS Lambda Edge or Lambda@Edge, lets user run AWS Lambda Functions across AWS edge locations globally using AWS-Cloudfront, which helps in sending responses to end users at the lowest latency.

AWS Lambda@Edge is a part of Amazon Web Services (AWS), which allows user to run AWS Lambda Functions across AWS edge locations globally.

It helps users in sending responses to their end users at the lowest latency by using AWS-CloudFront.

Lambda functions can be triggered by CloudFront events, such as requests for content to or from origin servers and viewers. Read More

Resources:

Documentation: What is AWS lambda@Edge?

Examples: Lambda@Edge

268 questions
7
votes
2 answers

Lambda@Edge Gives 502 only for SOME images

What we do is take a request for an image like "media/catalog/product/3/0/30123/768x/lorem.jpg", then we use the original image located at "media/catalog/product/3/0/30123.jpg", resize it to 768px and webp if the browser supports that and then…
OZZIE
  • 6,609
  • 7
  • 55
  • 59
7
votes
3 answers

How can I change status code in viewer-response Cloudfront event?

I want to secure Cloudfront response using S3 object metadata and some role data in DB (or some remote service), specif for current user. I think I should use viewer-response event here, to have access to S3 data and user data together. I try to set…
7
votes
2 answers

lambda@edge not getting triggered with cloudfront

I am using lambda@edge to redirect my sites with cloudfront. I have attached my versioned lambda arn to my cloud front cache behavior to all 4 events it has. when i hit my cloudfront endpoint it says 502 ERROR The request could not be…
Vishnu Ranganathan
  • 1,277
  • 21
  • 45
6
votes
1 answer

Lambda@Edge Cannot read properties of undefined (reading 'startsWith')

I'm trying to deploy a lambda@edge function (an AWS Lambda function that modifies HTML coming from a Cloudfront distribution) and get this cryptic response on save: Does anyone know what Cannot read properties of undefined (reading 'startsWith') is…
duhaime
  • 25,611
  • 17
  • 169
  • 224
6
votes
1 answer

How to fix 503 error with resize image lambda edge functions on cloudfront?

I am trying resize images with a cloudfront distribution accoring to article : https://aws.amazon.com/tr/blogs/networking-and-content-delivery/resizing-images-with-amazon-cloudfront-lambdaedge-aws-cdn-blog/ I created project folder with given…
6
votes
1 answer

Caching options for AWS Lambda@Edge

What is the best way to implement local caching for AWS Lambda@Edge? Here is the context: We have lambda@edge trigger in CloudFront that needs to retrieve a public key from public internet. This key rotates periodically. Making public call from…
6
votes
1 answer

rewrite cloudfront origin host with lambda@edge, how?

I see people talking about how to rewrite a URI based on various information. But I'd like to normalize the domain name that is being requested. Here's what I've tried: exports.handler = (event, context, callback) => { const request =…
tedder42
  • 23,519
  • 13
  • 86
  • 102
6
votes
4 answers

Bypassing need for x-amz-cf-id header inclusion in S3 auth in cloudfront

I have a not completely orthodox CF->S3 setup. The relevant components here are: Cloudfront distribution with origin s3.ap-southeast-2.amazonaws.com Lambda@Edge function (Origin Request) that adds a S3 authorisation (version 2) query string (Signed…
6
votes
1 answer

Prevent CloudFormation to remove Lambda Edge associations from CloudFront

I'm using CloudFormation to manage a CloudFront distribution. On this CloudFront distribution I've associated a Lambda Edge function (without using CloudFormation). The problem is later, when I update the CloudFront distribution with the same…
5
votes
1 answer

How to Deploy NextJs SSR app on Amplify with Lambda@Edge (503 Error)

I'm currently able to build and deploy Next.js app on Amplify where it automatically detects my .yml file in the root directory and automatically creates resources(Default Edge Lambda, Cloudfront Distribution, S3 bucket) to facilitate the hosting…
Ibra
  • 912
  • 1
  • 12
  • 31
5
votes
0 answers

Should I use Custom Authorizer or Lambda@edge to secure my API

I want to lock down my API and I am wondering the best way to do this. I have approx 20 micro services that are using API gateway with a proxy that has a custom authorizer. This has a cloudfront distribution. The issue with sending through an…
5
votes
2 answers

Shouldn't we all migrate to Lambda@Edge from API-Gateway + Lambda stack for API serving?

Serving APIs from Lambda@Edge offers more latency benefit than serving APIs from API-Gateway + Lambda stack, if my understanding is correct. Plus, cost of API-Gateway ($3.5/million call) + Lambda ($0.2/million call) == $3.7 / million call seems to…
5
votes
1 answer

Trigger another Lambda function from Lambda@Edge

I would like to offload some functionality from my Lambda@Edge to speed up response time. This would mean triggering another Lambda Function inside my Lambda@Edge. Lambda@Edge distributes the application across all regions, so when a request is made…
5
votes
1 answer

Validation error when I replace body in Lambda@Edge origin request function

I have Cloudfront in front of an s3 bucket that serves HLS videos. I'm trying to dynamically modify the manifest files to add an auth token to the segments inside of them. What I would really like to do is modify the body I send back to the client…
Dan
  • 641
  • 9
  • 25
5
votes
2 answers

.NET Core cookie authentication with AWS Lambda not persisting

I am unable to get cookie authentication working with an AWS Lambda function using .NET Core 2.1 MVC. I have tried lots of variations of the cookie options. I am able to login and see the asp cookie being created in the response, but I am returned…
1
2
3
17 18