281 questions
0 votes
0 answers
67 views
Setting the CloudFront-Viewer-Country to each viewer response
In the AWS CloudFront distribution, I can configure the origin request policy to add CloudFront-Viewer-Country header to the origin request, and I can read that header in the Lambda@Edge attached to ...
2 votes
1 answer
174 views
How to effectively update AWS Lambda@Edge functions in CDK after initial deployment?
I'm working with AWS CDK and have a Lambda@Edge function that needs to be updated after initial deployment. I understand that Lambda@Edge functions have replication limitations and can't be updated in ...
1 vote
1 answer
82 views
Can I return just HTML using a Lambda @ Edge?
I'm trying to use Lambda at Edge, and based on the status of the request, to return some HTML. Basically the following is my Lambda code (in Python): def handler(event, context): clientIp = event['...
4 votes
2 answers
86 views
How to investigate repeated cached lambda at edge requests
I have the following Cloudfront and lambda at edge setup User makes a request to CDN (path is irrelevant, result must always be the same for given day) Cloudfront makes request to origin (lambda is ...
0 votes
1 answer
141 views
How to securely handle AWS credentials in React app using DynamoDB SDK
I have a React application that directly connects to DynamoDB using the AWS SDK V3. Currently, the AWS credentials are stored in environment variables (.env), but I've discovered they're exposed to ...
1 vote
1 answer
275 views
Lambda@edge error handling with async/await (nodejs)
I've been creating lambda@edge functions to do various actions on a viewer request event from cloudfront. Most examples I can find seem to use callbacks but I wanted to use the async/await pattern ...
-1 votes
1 answer
145 views
How to add resource based policy to lambda?
asset_new_lambda = lambda_.Function( self, id=prefix + "asset_new", runtime=lambda_.Runtime.PYTHON_3_9, handler="asset.lambda_handler", code=lambda_.Code....
0 votes
0 answers
140 views
How to use Lambda@Edge in CloudFront to block an IP address
We use a CF distribution and ALB that connects to EC2 instances to provide API endpoints to the internet. On those EC2s we have an API system with many endpoints. They all start with api.company.com ...
0 votes
1 answer
127 views
AWS Cloudfront with lambda at edge failing
I'm trying to create a very simple frontend with AWS S3, AWS Cloudfront and an AWS Lambda at edge for protection. The frontend is very simple and contains no sensitive information (I just don't want ...
0 votes
2 answers
125 views
Simple server side request tracking with lambda@edge
My goal is for a lambda@edge function running on a Cloudfront viewer request event to record to DynamoDB every page request, this will be used later on for tracking activity and producing reports for ...
1 vote
1 answer
330 views
How to Configure AWS CloudFront to Cache Responses Based on Host Header Value?
I'm currently using AWS CloudFront to distribute requests to an Application Load Balancer (ALB), which then forwards them to EC2 instances. I need to configure caching based on the Host header value. ...
2 votes
0 answers
128 views
How to do fire and forget async call in AWS Lamda Edge function
I am using AWS lamda function as Lamda Edge function for my CloudFront setup. This Lamda function needs to call another service to send some metrics data. This operation is non blocking and needs to ...
0 votes
0 answers
49 views
How to make CloudFront to deliver an old version of the page?
How to make CloudFront to always deliver an old version of the page, not asking the origin again, unless this query was never received before? (well, with some timeout, like 3600sec after which a ...
1 vote
0 answers
216 views
Lambda@Edge to Cloudfront Results in a 502 Error, but works when testing?
I'm trying to recreate the AWS Image Optimization Example. In the example, the end result is to have a CloudFront Distro sitting on top of your S3 bucket that can do very basic image manipulations ...
0 votes
2 answers
737 views
How to set S3 bucket path in Cloudfront origin request using Lambda Edge?
I have an S3 bucket where each folder in the root contains a website with the folder name being the website url. I have a Cloudfront distribution with this bucket as an origin and a Lambda Edge ...