serverless-client-s3 icon indicating copy to clipboard operation
serverless-client-s3 copied to clipboard

Enhancement: Manage Cloudfront distributions for client code

Open andreipopovici opened this issue 9 years ago • 3 comments

Hi there,

Back in the days of JAWS, there was an interesting plugin: https://github.com/boushley/awsm-cloudfront

Basically, it would set up a Cloudfront distribution with two origins, one for static client code on S3 and another with the serverless API Gateway endpoints (using a base-path, like /api/). It would then be trivial to redirect to the distribution URL via Route 53 or others.

This might be a job for a separate plugin that has serverless-client-s3 as a dependency and also sets up the serverless API part.

I thought I'd bring it up here :)

andreipopovici avatar Apr 13 '16 15:04 andreipopovici

This would be a very useful feature.

konrad-garus avatar May 24 '16 09:05 konrad-garus

One thing to consider in the implementation is how to handle cache invalidation. Cloudfront offers 1000 individual invalidations per month free, and the cost could skyrocket for say, a static site with many pages.

However, changing the S3 origin path is free. Thus, uploading to a hashed folder name on S3 on each deploy, then changing the origin path to that folder is faster and cheaper.

andreipopovici avatar May 24 '16 10:05 andreipopovici

Could use Lambda@Edge to dynamically define a versioned path for assets. http://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html

andrewluetgers avatar Dec 27 '16 04:12 andrewluetgers