Closed mAiNiNfEcTiOn closed 4 years ago
So, I was checking your index.js
and I noticed this line here: https://github.com/serverless-operations/serverless-lambda-edge-pre-existing-cloudfront/blob/7637be062df9b1493493d330f874b47024cf6996/index.js#L14
I don't know serverless
's API on the getAllFunctions()
but if it returns an array and that is the native Array.forEach
then, bear in mind that the forEach doesn't wait for the completion of the await
's to continue the processing... Is this intentional?
Otherwise an either chained Array.reduce
, or a simple for
loop that could respect the await
keyword would be more interesting, no?
If you're interested I can create a PR for it, just let me know :)
Hi guys,
First of all, thank you for the work done with this. It's unfortunate that serverless doesn't handle this automatically and this library is really helpful.
When my
serverless.yml
only contained 1 lambda@edge (eventType: origin-request) everything went smoothly. However when I added a second function (eventType: viewer-request) CloudFormation started returning 412 (precondition failed).Initially I thought I had something wrong with my function and I did several attempts including making the changes manually... All of them worked.
Then I tried switching the order of the functions (moving the Viewer-Request one to be created first). Still got a 412, but on the second one (which was now the Origin-Request one).
With that said, it seems that the solution would be to add a delay, a retry, or a wait until updateDistribution is done and changes are made so that you can run the second updateDistribution.
Otherwise this becomes a limitation for updating a CF Distribution.
Let me know if you need more info, or what am I missing :)
Thank you for your time! 👍 Keep up the good work and stay safe!