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
질문됨 7달 전381회 조회
2개 답변
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
답변함 7달 전
0
수락된 답변

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
전문가
답변함 7달 전
  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠