serverless-nextjs / serverless-next.js

⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
MIT License
4.44k stars 454 forks source link

Allow the static content bucket to be specified externally when using NextJSLambdaEdge. #1553

Open daleobrien opened 3 years ago

daleobrien commented 3 years ago

I'd like to be able to pass in an S3 bucket name and optional prefix path and have NextJSLambdaEdge use that to store my static content rather than create its own S3 bucket.

We deploy a stack for each of our customers and AWS has an account limit of 1000 on the total number of S3 buckets.

dphang commented 3 years ago

Yes, this would be a useful enhancement - though not quite as simple as it looks.

We could ensure a prefix is added to all s3 paths in Lambdas, though it would currently break the _next/static and /static CloudFront paths since those go directly to the s3 bucket (and now these would have a prefix), so we would have to attach a Lambda to those as well. Ideally they'd only be attached when a prefix is being used, as adding a Lambda adds latency to CloudFront access, due to cold starts and the like.

daleobrien commented 3 years ago

I'd be happy without the prefix as it would still help. It could even help if each stack shared identical content.

dphang commented 3 years ago

@daleobrien sure, feel free to send an email to serverlessnextjs@gmail.com and I will send you a slack invite where it'll be easier to discuss these things. Unfortunately I'm the only core contributor right now so resourcing has been hard, and any help will be appreciated 👍