How do I reload a Lambda@Edge function after changing the configuration

0

I have deployed a cloudformation stack using the cloudfront-authorization-at-edge template and now I have a Lambda@Edge application called 'serverlessrepo-cloudfront-authorization-at-edge'. This template serves up a static site from S3 and injects the code to divert to Cognito for user/password protection. Everything is working pretty well so far.

Since I am a bit of a newbie I have been doing everything through the AWS web-based console, not the cli.

There is a problem that I need to change a few of the httpHeader parameters that are used by the httpHeadersHandler function. I found these parameters in the configuration.json file within the httpHeadersHandler code source of my lambda@edge function. I made the changes that I need to do (alter the Content-Security-Policy), saved the file, and clicked on the Deploy button.

Now what? How to I get these changes to propagate out to the edge? I tried reloading my page but the response headers still show the original version of the headers.

I then published a new version of the function. After waiting for it to deploy I cleared the cache and reloaded the page again. The response headers were the same as the original, but the code source for the version that was deployed does have the changes.

What do I need to do using the console do get the live handler to use my new configuration data?

Opeongo
asked 6 months ago340 views
2 Answers
1

Hi,

I think you already tried to invalidate the Cloudfront cache. Please ensure you did it correctly following the steps mentioned in this doc [1].

Also, after publishing the new version of the Lambda function, please make sure to update the Cloudfront distribution with the latest Lambda ARN.
Refer to these links to update it. [2] [3]

References:
[1] https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#Invalidation_Requests
[2] https://stackoverflow.com/questions/62655805/how-to-update-lambdaedge-arn-in-cloudfront-distribution-using-cli
[3] https://docs.imperva.com/bundle/advanced-bot-protection/page/77891.htm

Thanks,
Atul

profile picture
answered 6 months ago
0
Accepted Answer

Hi,

Please, read the guidance of this page https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-edit-function.html

and make sure that you implement properly steps 8 and beyond to get your new version in place in the existing CloudFront distribution

Best,

Didier

profile pictureAWS
EXPERT
answered 6 months ago
  • Thanks for that, I have it going now. Perhaps the problem was that I was reusing the trigger from the previous version. Creating a new trigger seemed to make it work. Also I had to invalidate the cache to get it to work.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions