serverless-nextjs / serverless-next.js

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

Question - can this be deployed to a normal lambda? #365

Open codetrove-development opened 4 years ago

codetrove-development commented 4 years ago

Hi,

I'm new to serverless and just want to deploy to a normal lambda in a stack. However with all the obscurity I dont know if I can deploy this with all the file caching setup etc to a normal lambda?

I require control over the region it is deployed to

Thanks

tyler-ground commented 4 years ago

I would also benefit from this. My servers are generally in Oregon and it doesn't make a lot of sense to hit a lambda in Asia then that has to send several requests to Oregon before proceeding.

I actually forked this project yesterday to change the node runtime but I must be missing something because my modified node_modules seemed to be skipped on deployment. If there's a simple guide to editing existing serverless plugins I may be able to create a PR for this.

Bathlamos commented 4 years ago

I would also benefit from this: while it makes sense to have the page lambda be deployed on Lambda@Edge, having the API lambda be deployed on a normal lambda would allow adding it to a VPC which would ease access to other protected AWS resources.

Bathlamos commented 4 years ago

I decided to try out my idea above and, to bypass API Gateway and CloudFormation, I ended up using a less than ideal solution of deploying a Lambda@Edge which simply forwards the request to a normal lambda. I could clean up the code and make a PR if the project maintainers deem that this is a direction they'd like to take: https://github.com/Bathlamos/serverless-next.js. I'd also love to hear if there's a cleaner solution

As an aside, this repo also makes the plugin compatible with Blitz.js by introducing the nextConfigFile input, which can be set to blitz.config.js if that's also of interest.

GitHub
Bathlamos/serverless-next.js
⚡ Deploy your next apps using the serverless framework - Bathlamos/serverless-next.js
firrae commented 3 years ago

This is big for me as well. I was planning to have my Blitz/Next app backed by a Postgres DB in a VPC so it could be more secure as well as cheaper. I don't have a need to run at the edge, but running on serverless in a single location makes a lot of sense today.

jaehyeon-kim commented 3 years ago

+1 It'll be good if APIG can be deployed in any of private, regional and edge endpoints.

emulienfou commented 3 years ago

Hi there, resurrecting this issue.

Has I can see there is multiple packages now:

When installing the package @sls-next/serverless-component I see it install the package @sls-next/lambda-at-edge also.

Does this mean in a near future we will be able to install one of the package managing normal lambda instead of Edge?

ixartz commented 2 years ago

I've created another issue and didn't find out it was a duplicate. Thanks to @tyler-ground, he points to this issue.

It would be great to have a way to choose if we want to deploy on Lambda or Lambda@Edge for the API routes. In the config file of serverless-next.js a way to choose between Lambda or Lambda@Edge

tyler-ground commented 2 years ago

It's challenging because there's a lot more to it than choosing a deployment target. This project is heavily dependent upon Cloudfront (arguably the correct course of action given the functionality needed to implement it) which does not overlap with the functionality that regular Lambda provides.

dphang commented 2 years ago

Yes I think @jvarho was working on Lambda support: https://github.com/serverless-nextjs/serverless-next.js/pull/1144 but not sure on the progress.

We created core library to encapsulate all the core routing logic that's not specific to a platform like Lambda@Edge, Lambda etc. And lambda-at-edge package should only contain logic to deploy to lambda-at-edge, although it's kind of coupled with routing logic for now. I should have more time after this month to work on this decoupling... the idea is that we will have different implementations in the future (lambda@edge, lambda, etc.)

ixartz commented 2 years ago

I understand the project is tied to Cloudfront and if I understand well, the project uses lambda-at-edge for routing logic by selecting where the resource are (either on S3, etc.). I don't know if it'll make things easier: deploy only the API backend on normal Lambda at the beginning.

Hopefully, the decoupling will be beneficial to the AWS CDK support. Anyway, good work for the project @dphang

jvarho commented 2 years ago

Yes I think @jvarho was working on Lambda support: #1144 but not sure on the progress.

Holidays are over and I should have time to work on it again next week.

Doesn't mean it'll be ready for use very soon, the deployment part is as yet unimplemented.