Comments (7)
Oh dear, I'm repeating myself 😂 #209 (comment)
from feral.
I've pushed a branch that shuffles the repo to setup for this.
https://github.com/typelevel/feral/tree/feature/custom-lambda-runtime
It:
- Extracts a
lambda-kernel
, withContext
,Events
, andTracedHandler
, but noIOLambda
. - The http4s and cloud formation integrations are now based on the kernel.
- Creates a
lambda-runtime
, which depends on kernel. This is where the runtime implementation will live.
- Adds Native cross-builds.
The idea is that:
- The core
lambda
module will eventually become an opinionated module with the AWS Java runtime for JVM, the AWS Node.js runtime for JS, and an Ember-client-based Feral runtime for Native (probably backed by epollcat, or maybe fs2-io_uring). This is how I expect it to be most commonly used on each platform. - Anyone that wants to use a different HTTP client on Native, or use the Feral runtime on JVM or JS, or even use a different effect type, can just do a custom thing with the
feral-lambda-kernel
andferal-lambda-runtime
modules.
from feral.
I was wondering if a custom runtime would let us more completely manage resource lifecycles (so that it could run the finalizers when the runtime shuts down, instead of skipping them like it does now). I'm not sure if that's actually supported or not either.
from feral.
That's a good idea, that one has bothered me as well. I don't see anything in the custom runtime docs about a shutdown phase, but I did look into this at least a couple times: there is a "Lambda Extensions" API (do you know anything about this?) that does get a shutdown hook:
Shutdown: This phase is triggered if the Lambda function does not receive any invocations for a period of time. In the Shutdown phase, Lambda shuts down the runtime, alerts the extensions to let them stop cleanly, and then removes the environment. Lambda sends a Shutdown event to each extension, which tells the extension that the environment is about to be shut down.
https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html
It's frustrating if the extension has access to this important lifecycle event, that the lambda itself does not.
from feral.
Not official by any means, but I found this:
AWS Lambda functions expose an internal API on localhost port 9001 that is meant for custom Lambda runtimes, but it is accessible from within an active invocation of a function. This means that if you get remote code execution or a server side request forgery vulnerability within a Lambda function, you can query that API. The
/2018-06-01/runtime/invocation/next
endpoint will return the event data that was passed into the function for that current execution, where you may be able to find secrets or other useful information to extend your attack into the environment.
The key words there being current execution. This suggests that until the response is given for the event in hand, that the endpoint will always return the same event (and not the next one). It is also notable that it is a GET
endpoint, so there should be no side-effect to calling it.
from feral.
I suppose it makes sense, considering how function calls will be retried in the event of an exception.
Oh well 🤷♂️
from feral.
So new thoughts on this: now that Scala Native support is slowly rippling through, would be super awesome to have Feral Native. This would necessitate writing our own Lambda runtime.
And in fact, said runtime would not have to be specific to Scala Native: it could be pure code that cross-compiles for all three platforms. Deploying a Lambda with a custom runtime is certainly more difficult, but it can also offer several advantages since we'd control all the threads and be able to allocate global resources without doing weird unsafe stuff.
This suggests we could benefit from an abstraction that allows the runtime to be swapped out on any platform, e.g. for the AWS JVM runtime or our own runtime.
from feral.
Related Issues (20)
- v0.1.0 HOT 4
- Lambda output empty with 1.0.0-M1 HOT 5
- natchez integration and lambda init HOT 3
- ES Module support HOT 19
- Giter8 Template(s) HOT 5
- Scala Native support HOT 1
- Idea: Simple and scalable mechanism for bundling lambdas into services HOT 8
- Make Feral more amenable to SnapStart optimization? HOT 1
- Should the return type of init really be a Resource? HOT 1
- Why not Dispatcher? HOT 4
- Add feral-otel4s integration
- Integrate feral-lambda with otel4s HOT 4
- Document how to deploy with scala-cli HOT 1
- feral example code Http4sLambda.scala does not work for JVM in AWS Lambda HOT 4
- Deprecate KinesisStreamEvent
- Can't print logs using `IO.println` HOT 2
- Support Vercel HOT 2
- 0.2.x -> 0.3.x scalafixes
- MiMa Configuration HOT 2
- Integrate http4s WebSocket app with AWS Lambda API Gateway
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feral.