| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A custom runtime layer that runs "Effectful" lambda functions. The idea is to have an option to implement lambda functions returning Effect type from effect library.
First, you will need to deploy the layer to your AWS account. Clone this repository and run the build-layer script to prepare the layer for distribution. Then run the publish-layer script to publish the layer to your AWS account.
git clone https://github.com/floydspace/aws-lambda-effect-runtime.git
cd aws-lambda-effect-runtime
pnpm install
pnpm publish-layerOnce you publish the layer to your AWS account, you can create a Lambda function that uses the layer.
Example of an effectful lambda handler implementing the EffectHandler type from @effect-aws/lambda:
import type { SNSEvent } from "aws-lambda"
import { Effect } from "effect"
import type { EffectHandler } from "@effect-aws/lambda"
// Define your effect handler
export const handler: EffectHandler<SNSEvent, never> = (event, context) => {
// Your effect logic here
return Effect.logInfo("Hello, World!")
}or with global layer:
import type { SNSEvent } from "aws-lambda"
import { Effect, Logger } from "effect"
import type { EffectHandlerWithLayer } from "@effect-aws/lambda"
// Define your effect handler with global layer
export const handler: EffectHandlerWithLayer<SNSEvent, never> = {
handler: (event, context) => {
// Your effect logic here
return Effect.logInfo("Hello, World!")
},
layer: Logger.pretty,
};The global layer will be constructed on lambda cold-start and finalized on shutdown. (How cool is that, huh!)
You can transpile your handler function to JavaScript or bundle it. Here's how you can do it using esbuild:
Note: Make sure you exclude effect and @effect/platform from the bundle. Those dependencies are provided by the layer.
Once you've written your Lambda function, you need to configure a new Lambda function to the layer. The following steps apply to configuring in the console, CloudFormation, CDK, Terraform, or any other configuration management option for AWS:
| Back | FazBrowse Home | New Git URL |