-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AWS API Gateway / Lambda Support (via AWS CDK) #26
Comments
@shortjared had the idea to use multiple CloudFront origins. With this we can serve all This has been implemented in m14t/starter-aws-cdk@1e32ff2 and can be seen working at https://d3cmgcnia7ll9p.cloudfront.net. 🎉 The With that all being said, there are certainly improvements that could be made, but I think this is a workable solution. Happy to hear any feedback, questions, or suggestions! |
Thank you for providing an initial Since over time some things have changed (added remix AWS Architect deployment option, aws-cdk v2 release, ...), I have built an example deployment based on the current project versions: It is based on the AWS Architect remix template (and still uses it for the local development). The deployment can be done via aws-cdk v2. |
@florianwiech , apologies for the newbie-type questions:
BTW, thank you VERY much for this offering 🙏🏾 |
Sure, it is totally fine to use other utilities for running scripts (eg. providing scripts inside the package.json as you mentioned). In my case I chose the If there are other questions regarding some |
Does anyone have a working version of Remix deployed via CDK? None of the projects mentioned in this thread seem to be maintained and work with latest Remix. |
@ryan-mars Thank you for pointing out that the latest release of remix introduced some breaking changes. Moreover, I introduced yarn workspaces for better project separation and extended the readme. |
@florianwiech Thanks! I got it to mostly work by disabling minifcation but even with your changes I still get bundler warnings... do you see this too?
|
@ryan-mars You're right, I get the same warnings. Here are some infos I could gather regarding the status of those warnings: Note to myself: Gosh I really have to add a dependabot to the example repo that there is some sort of automation on keeping it up-to-date. |
@florianwiech Thank you so much! |
removes bundling warnings: remix-run/remix#26 (comment)
First, thank you for all the work you've already done here! I'm really excited about Remix. I primarily use AWS for my infrastructure, and so I wanted to see if I could get this working with Lambdas deployed via CDK.
Current Progress
Thanks in part to some code posted by @shortjared on Discord (who has started this repo https://github.com/shortjared/remix-cdk-starter), I was able to make some pretty good progress. You can see it running here: https://y9beilufg0.execute-api.us-east-1.amazonaws.com/
I posted the code for this at m14t/starter-aws-cdk, which is a mono-repo with 3 projects:
serveStaticFileIfExists
- It would be great if this could stat the files to send the last modified header and calculate an etag, and to take those into account in the responsepublicPath
seems to be a part of thebrowserBuildDirectory
, which required some funky path/string manipulation to get working -- I'm sure this can be improved@remix-run/express
binding supported streams, but API Gateway doesn't. I'm not sure if its possible forhandleRequest
to return a stream here, but if it is, we'll need to consolidate it here.event.headers
andevent.multiValueHeaders
. The difference can be seen when someone sends the same header name twice, but with different values. Right now this code is only handling non-repeated headers.remix-run-apigateway
remix-starter-apigateway
Issues
Edit: Solved! See comment below.
However there seems to be one major limitation with API Gateway. From https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html:This is an issue for the way we are serving thebuild/_shared/node_modules
that contain an@
character in their package namespace. This effects the@babel/runtime
and@remis-run/react
dependencies specifically. If you look at the CloudWatch logs, the lambda function is never ever triggered for these requests, API Gateway seems to just drops them.Potential Solution
One thing that would make this setup slightly more complex, but follow best practices, is if we deployed the built assets to S3 and served them via CloudFront. I don't believe that CloudFront has the same path character limitations, which should allow us to work around this issue, and avoid a lambda execution for a static file.That being said, we might need some support in Remix to be able to serve these files from a different (sub)domain.The text was updated successfully, but these errors were encountered: