silvermine / serverless-plugin-cloudfront-lambda-edge

Adds Lambda@Edge support to Serverless
MIT License
296 stars 41 forks source link

Question: support for "deploy function"? #46

Closed MaxMotovilov closed 4 years ago

MaxMotovilov commented 4 years ago

I am considering serverless for the purpose of managing [primarily] the CloudFront stack consisting of a large number of behaviors and lambdas undergoing active development. It appears that the cloudfront-lambda-edge plugin addresses the issues inherent in deployment of the entire stack via CloudFormation, but is there a way to make the deploy function work with edge lambdas?

Specifically, the use case I have in mind is this:

It doesn't appear that serverless with or without the plugin would do more on deploy function than create a new version of the function. Am I wrong? Are there other tools/approaches that I am unaware of that address this use case?

Thanks in advance for all ideas and suggestions.

jthomerson commented 4 years ago

You're right that deploy function just creates a new version of the function itself. What you request, though, is not possible. To update the CloudFront trigger to point to the new version of the function requires an update to CloudFront itself. That, of course, takes the agonizing 30-45 minutes that every update to a CloudFront distribution takes. There's no way we can get around that.

Unfortunately, there's no such thing as "quickly deploy[ing] and test[ing]" Lambda@Edge functions. I recommend heavy use of unit testing. Fortunately, Lambda@Edge functions are generally very simple, and unit testing them is thus fairly easy and highly effective.