nitro icon indicating copy to clipboard operation
nitro copied to clipboard

feat: add `aws-lambda-edge` preset with CDK

Open WinterYukky opened this issue 3 years ago • 18 comments

🔗 Linked issue

  • #79

❓ Type of change

  • [ ] 📖 Documentation (updates to the documentation or readme)
  • [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ ] 👌 Enhancement (improving an existing functionality like performance)
  • [x] ✨ New feature (a non-breaking change that adds functionality)
  • [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Add AWS Lambda@Edge to the preset.

The current aws-lambda preset is not compatible with the Lambda@Edge format and requires users to create their own wrapper for Lambda@Edge. This PR is needed to resolve this issue.
It would also be very powerful if Lambda@Edge were available in Nitro. It will be quite important for projects that require SSR (e.g Nuxt3) as static assets (.output/public) can be retrieved from AWS S3 and the rest (.output/server) can be resolved by Lambda@Edge.

Resolves #79

📝 Checklist

  • [x] I have linked an issue or discussion.
  • [x] I have updated the documentation accordingly.

WinterYukky avatar May 15 '22 08:05 WinterYukky

I support this PR :)

(@WinterYukky You might consider a review request?)

mirumirumi avatar Jun 11 '22 07:06 mirumirumi

@mirumirumi Thanks your comment!

Also, thank you @danielroe and @pi0 for reviewing🥰

WinterYukky avatar Jun 11 '22 14:06 WinterYukky

Hi @WinterYukky Thanks for your works on this pull request and sorry review took long.

I will have to try the deployment and probably pushing some improvements to automate as much as possible for sdk use. (Hense self assigned).

pi0 avatar Jun 23 '22 21:06 pi0

Hi @pi0. I updated to automatically generate CDK code to the .output. Can you please re-review it?

WinterYukky avatar Jul 09 '22 13:07 WinterYukky

@pi0 do we plan to release this change before nuxt stable release?

anjali89r avatar Sep 21 '22 01:09 anjali89r

@danielroe do we plan to release this support before the stable release?

anjali89r avatar Nov 01 '22 01:11 anjali89r

@anjali89r Yes, I will make sure I review it soon.

danielroe avatar Nov 01 '22 08:11 danielroe

Codecov Report

Merging #240 (69049af) into main (e8fa771) will decrease coverage by 51.95%. Report is 6 commits behind head on main. The diff coverage is n/a.

:exclamation: Current head 69049af differs from pull request most recent head 08a5111. Consider uploading reports for the commit 08a5111 to get more accurate results

@@            Coverage Diff            @@
##             main   #240       +/-   ##
=========================================
- Coverage   51.94%      0   -51.95%     
=========================================
  Files         174      0      -174     
  Lines       12035      0    -12035     
  Branches      913      0      -913     
=========================================
- Hits         6252      0     -6252     
+ Misses       5686      0     -5686     
+ Partials       97      0       -97     

see 174 files with indirect coverage changes

codecov[bot] avatar Nov 01 '22 17:11 codecov[bot]

Thank you for your reviewing @danielroe! branch was out of date, so the latest changes were incorporated.

Also, as mentioned in https://github.com/unjs/nitro/pull/240#discussion_r907183618, I have created a small utility package for customers who want to customize their CDK projects. And I experimentally distribute it via NPM. It would be nice if this package could also be managed by unjs. How about it? https://github.com/WinterYukky/nitro-aws-cdk-lib

WinterYukky avatar Nov 01 '22 18:11 WinterYukky

@danielroe any plan to support this preset soon ,? I believe there are lots of teams waiting for this PR to be merged to host nuxt ssr at the lambda edge

galaxy79 avatar Jan 04 '23 02:01 galaxy79

@pi0 anyway this PR can be also part of the 2.0 release?

anjali89r avatar Jan 21 '23 14:01 anjali89r

Live Preview ready!

Name Edit Preview Latest Commit
nitro Edit on Studio ↗︎ View Live Preview 3b2d3e718511309225e4090a4ce86c8c970eb139

nuxt-studio[bot] avatar May 17 '23 11:05 nuxt-studio[bot]

Any news about this pr? This is quite important for AWS use cases, as stated here: https://github.com/unjs/nitro/discussions/1106

ennioVisco avatar May 28 '23 08:05 ennioVisco

@danielroe @pi0 I've noticed that there's 2 PR open for aws-lamba-edge

  • https://github.com/unjs/nitro/pull/240
  • https://github.com/unjs/nitro/pull/1075

Which one should get merged ?

Hebilicious avatar May 28 '23 11:05 Hebilicious

@danielroe @pi0 I've noticed that there's 2 PR open for aws-lamba-edge

Which one should get merged ?

the other one is newer, although it seems very similar to this one, while this one also has CDK and github action setup, which is very interesting!

ennioVisco avatar Jun 26 '23 09:06 ennioVisco

Users deploying through IaC (SST/Terraform/Pulumi/Cloudformation) other than CDK and would find Cloudfront wrapper useful. It would require decoupling it from the CDK deployment.

Possible solutions could be to:

  1. Alter this pr to make CDK deployment optional and keep the Cloudfront handler wrapper.
  2. Create two presets (possibly extend one off the other):
  • aws-lambda-edge
  • aws-lambda-edge-cdk

jdevdevdev avatar Jun 26 '23 16:06 jdevdevdev

Thanks for your reviewing @Hebilicious. I'm busy this week, so I'll fix this PR next week in line with your comments 😉.

WinterYukky avatar Jul 04 '23 11:07 WinterYukky

@Hebilicious Thanks your reviewing!! I fixed lined by your comment. However I'm not understand your strategy about to merge two PRs. Should I merge to this PR from https://github.com/unjs/nitro/pull/1075?

WinterYukky avatar Nov 04 '23 14:11 WinterYukky