question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decouple lambda-at-edge deploy logic from nextjs-component

See original GitHub issue

Currently, the Lambda@Edge deploy logic is actually coupled into nextjs-component.

As a first step to making this package more generic and extensible for supporting other serverless platforms (e.g Lambda, Cloudflare), all Lambda@Edge logic should live in the lambda-at-edge package. It would be a plugin and implement two features:

  • Build (already done): builds artifacts for deploying to Lambda@Edge. Ex: default-handler, api-handler, assets (building of assets for S3 was recently decoupled from component to lambda-at-edge).
  • Deploy: we need to move all deployment logic currently from nextjs-component into lambda-at-edge. Currently, it’s doing all the CloudFront, S3 and Lambda deployment work, but this should really live in lambda-at-edge. Of course, if there’s shared logic (e.g S3 upload logic may be same for Lambda vs. Lambda@Edge), then we’ll put those in the respective internal packages.

As part of this, we can define a standard interface that all plugins should implement.

Afterwards, nextjs-component itself will be very lightweight and simply call the plugin to use based on inputs (e.g lambda-at-edge for now, and others later).

I also suggest to rename lambda-at-edge to lambda-at-edge-plugin to be clearer later on.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielcondemarincommented, Oct 28, 2020

If we go with CDK for Terraform, do we need to remain on Serverless in that case?

We could possibly remove the need for Serverless whilst still supporting serverless components via https://github.com/serverless-components/aws-cloudformation 🤩 Tempting.

1reaction
danielcondemarincommented, Oct 27, 2020

Thanks for the thought out reply, overall sounds very sensible to me 🙂

For example, it doesn’t know to use AWS S3 for retrieving static pages. For that, it would just call a storage accessor interface (which can later be replaced e.g by Rollup.js by the actual implementation when bundling).

This would be quite nice 💯

The proposal to introduce a new platform sounds really good as well. Possibly an easy first candidate would be Lambda + API Gateway.

As an aside: since CDK is from AWS, it would be well-supported for AWS platforms, but maybe others may not be as well supported.

I used CDK as an example. I was trying to convey it would be nice if we supported other deployment / IaC frameworks such as CDK or Terraform.

However, if we use something like CDK, we could enforce all Deploy implementations use the CDK to make it more maintainable overall.

There is an interesting trade-off to consider here. Whilst it makes it easier for us to maintain, it means enforcing a particular way of deploying to users. For example, some people will use CDK, others Terraform etc. Ideally serverless-next.js would provide different entry points for each. That way it integrates nicely with existing tools folks already use for their IaC projects.

CDK for Terraform sounds quite interesting and potentially a really good fit for this project. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying Next.js to AWS using Serverless Next.js
Learn how to deploy a Next.js application to AWS Lambda in Serverless Mode using the Serverless Next.js Component.
Read more >
Serverless Next.js Component - Morioh
It is the component's job to deploy your application ensuring parity with all of next's features we know and love. We try to...
Read more >
Serverless Next.js Component - Serverless Framework: Plugins
We try to emulate all or most of the routing and server-side logic from Next.js and optimize it for a serverless environment. Below...
Read more >
Testing a new CDK Construct to deploy a Serverless NextJS ...
One tremendous gap, specially for me, was a good way to deploy React apps on AWS ... Source: Serverless Next.js Component GitHub repository....
Read more >
Deploy logic app templates - Azure - Microsoft Learn
Deploy Azure Resource Manager templates for Azure Logic Apps · In this article · Deploy through Azure portal · Deploy with Visual Studio...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found